From dff699d663e82c67ea99bf7628c1e699d0f9830f Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Mon, 13 Jul 2026 12:42:24 -0700 Subject: [PATCH 1/3] Add a checked-in baseline test harness for the generator tests Introduce infrastructure for asserting generator output against checked-in baseline files instead of inline escaped expectedOutputContents strings. The harness resolves a baseline for a given (case, mode, config, os) via a fallback chain -- most-specific to shared -- so identical output across variants is stored once. Baselines are real .cs/.xml files (excluded from compilation) for syntax highlighting and readable diffs, and can be regenerated by running the suite with UPDATE_BASELINES=1. BaselineTest is the parameterized base for the 16-way matrix fixtures; StandaloneBaselineTest is the single-config base for the root-level fixtures. Both reuse a shared GenerateBindingsAsync core factored out of the existing inline harness so the two styles generate output identically. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../Baseline/BaselineAssertions.cs | 31 +++ .../Baseline/BaselineHarness.cs | 226 ++++++++++++++++++ .../Baseline/BaselineTest.cs | 56 +++++ .../Baseline/StandaloneBaselineTest.cs | 54 +++++ ...angSharp.PInvokeGenerator.UnitTests.csproj | 9 + .../PInvokeGeneratorTest.cs | 10 +- 6 files changed, 385 insertions(+), 1 deletion(-) create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineAssertions.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineHarness.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineTest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/StandaloneBaselineTest.cs diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineAssertions.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineAssertions.cs new file mode 100644 index 00000000..9ab3effb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineAssertions.cs @@ -0,0 +1,31 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System.IO; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace ClangSharp.UnitTests.Baseline; + +// Shared baseline read/write core used by both the matrix-parameterized BaselineTest and the +// single-variant StandaloneBaselineTest. Given the already-generated output for a case+variant, it either +// (re)writes the checked-in baseline under UPDATE_BASELINES, or resolves the baseline via the fallback +// chain and asserts byte-for-byte equality. +internal static class BaselineAssertions +{ + public static async Task AssertOrUpdateAsync(string area, string caseName, BaselineVariant variant, string actual) + { + if (BaselineHarness.ShouldUpdateBaselines) + { + var path = BaselineHarness.MostSpecificPath(area, caseName, variant); + _ = Directory.CreateDirectory(Path.GetDirectoryName(path)!); + await File.WriteAllTextAsync(path, actual).ConfigureAwait(false); + return; + } + + var resolved = BaselineHarness.ResolveBaselinePath(area, caseName, variant); + Assert.That(resolved, Is.Not.Null, $"No baseline found for case '{caseName}' variant '{variant}'. Run with UPDATE_BASELINES=1 (Windows variants) or seed from the legacy tests (Unix variants)."); + + var expected = await File.ReadAllTextAsync(resolved!).ConfigureAwait(false); + Assert.That(actual, Is.EqualTo(expected)); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineHarness.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineHarness.cs new file mode 100644 index 00000000..dca097c2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineHarness.cs @@ -0,0 +1,226 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.UnitTests.Baseline; + +// Baseline harness (Approach 2): checked-in baseline files resolved with a +// {Case}.{Mode}.{Config}.{OS} -> {Case}.{Mode}.{Config} -> {Case}.{Mode} fallback chain, so output that +// is identical across variants is stored once. Baselines are read from the source tree during local runs +// and from a copy next to the test assembly on CI (see the csproj), and are (re)written to the source tree +// by the UPDATE_BASELINES workflow. + +public enum BaselineConfig +{ + Compatible, + Default, + Latest, + Preview, +} + +public static class BaselineConfigExtensions +{ + // The config-only configuration flags (no GenerateUnixTypes), shared by BaselineVariant.ConfigOptions and + // the host-keyed standalone cases that must not fold in the OS flag. + public static PInvokeGeneratorConfigurationOptions ToConfigOptions(this BaselineConfig config) => config switch { + BaselineConfig.Compatible => PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode, + BaselineConfig.Latest => PInvokeGeneratorConfigurationOptions.GenerateLatestCode, + BaselineConfig.Preview => PInvokeGeneratorConfigurationOptions.GeneratePreviewCode, + _ => PInvokeGeneratorConfigurationOptions.None, + }; +} + +public enum BaselineOs +{ + Windows, + Unix, +} + +public readonly record struct BaselineVariant(PInvokeGeneratorOutputMode Mode, BaselineConfig Config, BaselineOs Os) +{ + public string ModeToken => Mode == PInvokeGeneratorOutputMode.Xml ? "Xml" : "CSharp"; + + public override string ToString() => $"{ModeToken}{Config}{Os}"; + + // Maps a variant onto the same (outputMode, configOptions) the legacy ValidateGenerated{Config}{OS} + // wrappers used, so the generated output is identical to the pre-migration harness. + public PInvokeGeneratorConfigurationOptions ConfigOptions + { + get + { + var options = Config.ToConfigOptions(); + + if (Os == BaselineOs.Unix) + { + options |= PInvokeGeneratorConfigurationOptions.GenerateUnixTypes; + } + + return options; + } + } + + public bool MatchesHost + { + get + { + var hostIsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + return Os == BaselineOs.Windows ? hostIsWindows : !hostIsWindows; + } + } +} + +public static class BaselineHarness +{ + public static readonly IReadOnlyList AllVariants = BuildAllVariants(); + + private static List BuildAllVariants() + { + var variants = new List(16); + + foreach (var mode in new[] { PInvokeGeneratorOutputMode.CSharp, PInvokeGeneratorOutputMode.Xml }) + { + foreach (var config in Enum.GetValues()) + { + foreach (var os in Enum.GetValues()) + { + variants.Add(new BaselineVariant(mode, config, os)); + } + } + } + + return variants; + } + + // Baselines are resolved from two roots so a test run works both locally and on CI. The source tree + // (located via [CallerFilePath]) is where the baselines live and are (re)written by UPDATE_BASELINES, + // and is preferred so a fresh update is picked up without a rebuild. CI builds are deterministic, so + // [CallerFilePath] is remapped to a non-existent path there; the copy placed next to the test assembly + // (wired up in the csproj) is the fallback that resolves on CI, mirroring how ClangUnsavedFile.h is + // copied to the output directory. + public static string SourceBaselinesRoot([CallerFilePath] string thisFilePath = "") + => Path.Combine(Path.GetDirectoryName(thisFilePath)!, "Baselines"); + + private static string OutputBaselinesRoot + => Path.Combine(AppContext.BaseDirectory, "Baseline", "Baselines"); + + private static IEnumerable BaselinesRoots() + { + yield return SourceBaselinesRoot(); + yield return OutputBaselinesRoot; + } + + public static bool ShouldUpdateBaselines + => Environment.GetEnvironmentVariable("UPDATE_BASELINES") is "1" or "true"; + + // The Clang target triple pinned for Unix variants. Without an explicit --target, clang parses with the + // host's default triple, so target-dependent output (C++ name mangling, type/pointer/long sizes, record + // layout) would be baked to whichever host generated the baseline. Pinning a fixed Unix triple makes the + // Unix baseline deterministic across every CI host (Linux and macOS produce identical output), so a single + // checked-in baseline is valid everywhere. Windows variants are only ever run on a Windows host (see the + // MatchesHost gating), so their host default is already the Windows triple and needs no pin. + public const string UnixTargetTriple = "x86_64-unknown-linux-gnu"; + + // When true, the MatchesHost gating is bypassed so every variant runs on the current host. Used to (re)write + // Unix baselines from a Windows box under UPDATE_BASELINES, and to validate them locally via RUN_ALL_VARIANTS, + // both of which rely on the pinned Unix triple to reproduce the Unix host's output deterministically. + public static bool RunAllVariants + => ShouldUpdateBaselines || Environment.GetEnvironmentVariable("RUN_ALL_VARIANTS") is "1" or "true"; + + // Appends the pinned Unix target triple for Unix variants, leaving Windows variants exactly as the caller + // specified (null flows through to the C++ default inside GenerateBindingsAsync). The base args mirror that + // same default so an explicit --target can be appended without otherwise changing the command line. + public static string[]? WithUnixTarget(string[]? commandLineArgs, string[] defaultCommandLineArgs, BaselineOs os) + { + if (os != BaselineOs.Unix) + { + return commandLineArgs; + } + + var baseArgs = commandLineArgs ?? defaultCommandLineArgs; + return [.. baseArgs, $"--target={UnixTargetTriple}"]; + } + + private static string Extension(PInvokeGeneratorOutputMode mode) + => mode == PInvokeGeneratorOutputMode.Xml ? "xml" : "cs"; + + // Candidate baseline file names, most-specific first, matching the documented fallback chain. + private static IEnumerable CandidateNames(string caseName, BaselineVariant variant) + { + var ext = Extension(variant.Mode); + var mode = variant.ModeToken; + + yield return $"{caseName}.{mode}.{variant.Config}.{variant.Os}.{ext}"; + yield return $"{caseName}.{mode}.{variant.Config}.{ext}"; + yield return $"{caseName}.{mode}.{ext}"; + } + + // Resolves the baseline that applies to a variant via the fallback chain; returns null when none exists. + public static string? ResolveBaselinePath(string area, string caseName, BaselineVariant variant) + { + foreach (var root in BaselinesRoots()) + { + foreach (var name in CandidateNames(caseName, variant)) + { + var candidate = Path.Combine(root, area, name); + + if (File.Exists(candidate)) + { + return candidate; + } + } + } + + return null; + } + + // The most-specific path, used when writing a fresh baseline before de-duplication collapses it. Writes + // always target the source tree so UPDATE_BASELINES updates the checked-in files, not the output copy. + public static string MostSpecificPath(string area, string caseName, BaselineVariant variant) + { + using var e = CandidateNames(caseName, variant).GetEnumerator(); + _ = e.MoveNext(); + return Path.Combine(SourceBaselinesRoot(), area, e.Current); + } + + // Filesystem-safe case token derived from the test method name plus any per-case discriminator. + // The method name is always a valid C# identifier (already filesystem-safe); the discriminator can be + // an arbitrary [TestCase] argument (operators like "%"/"|", pointer types like "int *"), so it is + // encoded injectively: letters/digits pass through, every other character becomes `_` + its hex code + // point. This is collision-free -- distinct discriminators always yield distinct tokens -- which the + // naive "replace every non-alphanumeric with `_`" scheme was not (e.g. `%`, `|`, `^`, `*` all collapsed + // to the same file, so per-operator baselines overwrote one another). + public static string CaseName(string method, string? discriminator = null) + { + ArgumentNullException.ThrowIfNull(method); + + return discriminator is null ? method : $"{method}_{Encode(discriminator)}"; + } + + private static string Encode(string discriminator) + { + var sb = new System.Text.StringBuilder(discriminator.Length); + + foreach (var c in discriminator) + { + if (char.IsAsciiLetterOrDigit(c)) + { + _ = sb.Append(c); + } + else if (c <= 0xFF) + { + _ = sb.Append('_').Append(((int)c).ToString("X2", CultureInfo.InvariantCulture)); + } + else + { + _ = sb.Append("_u").Append(((int)c).ToString("X4", CultureInfo.InvariantCulture)); + } + } + + return sb.ToString(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineTest.cs new file mode 100644 index 00000000..687e6e87 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineTest.cs @@ -0,0 +1,56 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System.Collections.Generic; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace ClangSharp.UnitTests.Baseline; + +// Base class for migrated, baseline-driven fixtures. A single fixture is parameterized over all 16 +// (Mode, Config, OS) variants via [TestFixtureSource]; each concrete test supplies the C/C++ input and a +// case name exactly once, and the expected output comes from a checked-in baseline file. +public abstract class BaselineTest : PInvokeGeneratorTest +{ + private readonly BaselineVariant _variant; + + protected BaselineTest(BaselineVariant variant) + { + _variant = variant; + } + + protected abstract string Area { get; } + + // The variant this fixture instance is exercising. Exposed so a migrated case can replicate a legacy no-op + // (a folder that stubbed its *Impl to Task.CompletedTask) for the specific variants it was never run under. + protected BaselineVariant Variant => _variant; + + // Feeds [TestFixtureSource]; Unix variants are ignored on Windows hosts (and vice versa), matching the + // legacy [Platform("win")] / [Platform("unix")] gating exactly. + protected static IEnumerable Variants() + { + foreach (var variant in BaselineHarness.AllVariants) + { + var data = new TestFixtureData(variant); + _ = data.SetArgDisplayNames(variant.ToString()); + + if (!variant.MatchesHost) + { + _ = data.Ignore($"{variant.Os} variant only runs on matching hosts"); + } + + yield return data; + } + } + + // Mirrors the full ValidateGeneratedCSharpLatestWindowsBindingsAsync surface (minus expectedOutputContents, + // which now lives in a checked-in baseline) so any migrated area can express its options exactly. The + // Mode/Config come from the fixture variant; additionalConfigOptions OR-in the area's positional flags. + protected Task ValidateAsync(string method, string inputContents, string? discriminator = null, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[]? excludedNames = null, IReadOnlyDictionary? remappedNames = null, IReadOnlyDictionary? withAccessSpecifiers = null, IReadOnlyDictionary>? withAttributes = null, IReadOnlyDictionary? withCallConvs = null, IReadOnlyDictionary? withClasses = null, IReadOnlyDictionary? withLibraryPaths = null, IReadOnlyDictionary? withNamespaces = null, string[]? withSetLastErrors = null, IReadOnlyDictionary? withTransparentStructs = null, IReadOnlyDictionary? withTypes = null, IReadOnlyDictionary>? withUsings = null, IReadOnlyDictionary? withPackings = null, IEnumerable? expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[]? commandLineArgs = null, string language = "c++", string languageStandard = DefaultCppStandard, IReadOnlyDictionary? remappedTypeNames = null, IReadOnlyDictionary? remappedFieldNames = null) + => ValidateCoreAsync(BaselineHarness.CaseName(method, discriminator), inputContents, additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, withPackings, expectedDiagnostics, libraryPath, commandLineArgs, language, languageStandard, remappedTypeNames, remappedFieldNames); + + private async Task ValidateCoreAsync(string caseName, string inputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions, string[]? excludedNames, IReadOnlyDictionary? remappedNames, IReadOnlyDictionary? withAccessSpecifiers, IReadOnlyDictionary>? withAttributes, IReadOnlyDictionary? withCallConvs, IReadOnlyDictionary? withClasses, IReadOnlyDictionary? withLibraryPaths, IReadOnlyDictionary? withNamespaces, string[]? withSetLastErrors, IReadOnlyDictionary? withTransparentStructs, IReadOnlyDictionary? withTypes, IReadOnlyDictionary>? withUsings, IReadOnlyDictionary? withPackings, IEnumerable? expectedDiagnostics, string libraryPath, string[]? commandLineArgs, string language, string languageStandard, IReadOnlyDictionary? remappedTypeNames, IReadOnlyDictionary? remappedFieldNames) + { + var actual = await GenerateBindingsAsync(inputContents, _variant.Mode, _variant.ConfigOptions | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, withPackings, expectedDiagnostics, libraryPath, commandLineArgs, language, languageStandard, remappedTypeNames, remappedFieldNames).ConfigureAwait(false); + await BaselineAssertions.AssertOrUpdateAsync(Area, caseName, _variant, actual).ConfigureAwait(false); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/StandaloneBaselineTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/StandaloneBaselineTest.cs new file mode 100644 index 00000000..0891d07d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/StandaloneBaselineTest.cs @@ -0,0 +1,54 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Threading.Tasks; + +namespace ClangSharp.UnitTests.Baseline; + +// Base class for the migrated single-configuration fixtures (formerly the standalone, root-level tests that +// asserted exactly one Mode/Config/OS rather than the full 16-way matrix). Each fixture exposes an Area name; +// each test supplies only the C/C++ input plus its options and names the one variant it exercises via a +// Validate* helper. The expected output lives in a checked-in baseline file, resolved by the shared harness. +// +// Unlike BaselineTest these fixtures are not parameterized: a given test asserts a single variant, so the +// [Platform("win")] / [Platform("unix")] gating carries over verbatim onto the concrete fixture or method. +public abstract class StandaloneBaselineTest : PInvokeGeneratorTest +{ + protected abstract string Area { get; } + + protected Task ValidateGeneratedCSharpLatestWindowsBaselineAsync(string inputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[]? excludedNames = null, IReadOnlyDictionary? remappedNames = null, IReadOnlyDictionary? withAccessSpecifiers = null, IReadOnlyDictionary>? withAttributes = null, IReadOnlyDictionary? withCallConvs = null, IReadOnlyDictionary? withClasses = null, IReadOnlyDictionary? withLibraryPaths = null, IReadOnlyDictionary? withNamespaces = null, string[]? withSetLastErrors = null, IReadOnlyDictionary? withTransparentStructs = null, IReadOnlyDictionary? withTypes = null, IReadOnlyDictionary>? withUsings = null, IReadOnlyDictionary? withPackings = null, IEnumerable? expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[]? commandLineArgs = null, string language = "c++", string languageStandard = DefaultCppStandard, IReadOnlyDictionary? remappedTypeNames = null, IReadOnlyDictionary? remappedFieldNames = null, [CallerMemberName] string testMethod = "") + => ValidateVariantAsync(new BaselineVariant(PInvokeGeneratorOutputMode.CSharp, BaselineConfig.Latest, BaselineOs.Windows), testMethod, inputContents, additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, withPackings, expectedDiagnostics, libraryPath, commandLineArgs, language, languageStandard, remappedTypeNames, remappedFieldNames); + + protected Task ValidateGeneratedCSharpLatestUnixBaselineAsync(string inputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[]? excludedNames = null, IReadOnlyDictionary? remappedNames = null, IReadOnlyDictionary? withAccessSpecifiers = null, IReadOnlyDictionary>? withAttributes = null, IReadOnlyDictionary? withCallConvs = null, IReadOnlyDictionary? withClasses = null, IReadOnlyDictionary? withLibraryPaths = null, IReadOnlyDictionary? withNamespaces = null, string[]? withSetLastErrors = null, IReadOnlyDictionary? withTransparentStructs = null, IReadOnlyDictionary? withTypes = null, IReadOnlyDictionary>? withUsings = null, IReadOnlyDictionary? withPackings = null, IEnumerable? expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[]? commandLineArgs = null, string language = "c++", string languageStandard = DefaultCppStandard, IReadOnlyDictionary? remappedTypeNames = null, IReadOnlyDictionary? remappedFieldNames = null, [CallerMemberName] string testMethod = "") + => ValidateVariantAsync(new BaselineVariant(PInvokeGeneratorOutputMode.CSharp, BaselineConfig.Latest, BaselineOs.Unix), testMethod, inputContents, additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, withPackings, expectedDiagnostics, libraryPath, commandLineArgs, language, languageStandard, remappedTypeNames, remappedFieldNames); + + protected Task ValidateGeneratedCSharpCompatibleWindowsBaselineAsync(string inputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[]? excludedNames = null, IReadOnlyDictionary? remappedNames = null, IReadOnlyDictionary? withAccessSpecifiers = null, IReadOnlyDictionary>? withAttributes = null, IReadOnlyDictionary? withCallConvs = null, IReadOnlyDictionary? withClasses = null, IReadOnlyDictionary? withLibraryPaths = null, IReadOnlyDictionary? withNamespaces = null, string[]? withSetLastErrors = null, IReadOnlyDictionary? withTransparentStructs = null, IReadOnlyDictionary? withTypes = null, IReadOnlyDictionary>? withUsings = null, IReadOnlyDictionary? withPackings = null, IEnumerable? expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[]? commandLineArgs = null, string language = "c++", string languageStandard = DefaultCppStandard, IReadOnlyDictionary? remappedTypeNames = null, IReadOnlyDictionary? remappedFieldNames = null, [CallerMemberName] string testMethod = "") + => ValidateVariantAsync(new BaselineVariant(PInvokeGeneratorOutputMode.CSharp, BaselineConfig.Compatible, BaselineOs.Windows), testMethod, inputContents, additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, withPackings, expectedDiagnostics, libraryPath, commandLineArgs, language, languageStandard, remappedTypeNames, remappedFieldNames); + + protected Task ValidateGeneratedCSharpCompatibleUnixBaselineAsync(string inputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[]? excludedNames = null, IReadOnlyDictionary? remappedNames = null, IReadOnlyDictionary? withAccessSpecifiers = null, IReadOnlyDictionary>? withAttributes = null, IReadOnlyDictionary? withCallConvs = null, IReadOnlyDictionary? withClasses = null, IReadOnlyDictionary? withLibraryPaths = null, IReadOnlyDictionary? withNamespaces = null, string[]? withSetLastErrors = null, IReadOnlyDictionary? withTransparentStructs = null, IReadOnlyDictionary? withTypes = null, IReadOnlyDictionary>? withUsings = null, IReadOnlyDictionary? withPackings = null, IEnumerable? expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[]? commandLineArgs = null, string language = "c++", string languageStandard = DefaultCppStandard, IReadOnlyDictionary? remappedTypeNames = null, IReadOnlyDictionary? remappedFieldNames = null, [CallerMemberName] string testMethod = "") + => ValidateVariantAsync(new BaselineVariant(PInvokeGeneratorOutputMode.CSharp, BaselineConfig.Compatible, BaselineOs.Unix), testMethod, inputContents, additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, withPackings, expectedDiagnostics, libraryPath, commandLineArgs, language, languageStandard, remappedTypeNames, remappedFieldNames); + + // For host-sensitive cases the legacy tests ran under a single config (no GenerateUnixTypes flag) but + // branched their expected output on the runtime host, since clang parses with the host target triple. + // Generation therefore uses the plain Latest config while the baseline is keyed by the current host, so + // the Windows-host and Unix-host outputs are stored side by side and each is asserted on its own host. + protected Task ValidateGeneratedCSharpLatestHostBaselineAsync(string inputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions = PInvokeGeneratorConfigurationOptions.None, string[]? excludedNames = null, IReadOnlyDictionary? remappedNames = null, IReadOnlyDictionary? withAccessSpecifiers = null, IReadOnlyDictionary>? withAttributes = null, IReadOnlyDictionary? withCallConvs = null, IReadOnlyDictionary? withClasses = null, IReadOnlyDictionary? withLibraryPaths = null, IReadOnlyDictionary? withNamespaces = null, string[]? withSetLastErrors = null, IReadOnlyDictionary? withTransparentStructs = null, IReadOnlyDictionary? withTypes = null, IReadOnlyDictionary>? withUsings = null, IReadOnlyDictionary? withPackings = null, IEnumerable? expectedDiagnostics = null, string libraryPath = DefaultLibraryPath, string[]? commandLineArgs = null, string language = "c++", string languageStandard = DefaultCppStandard, IReadOnlyDictionary? remappedTypeNames = null, IReadOnlyDictionary? remappedFieldNames = null, [CallerMemberName] string testMethod = "") + { + var hostOs = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? BaselineOs.Windows : BaselineOs.Unix; + var variant = new BaselineVariant(PInvokeGeneratorOutputMode.CSharp, BaselineConfig.Latest, hostOs); + return ValidateVariantAsync(variant, testMethod, inputContents, additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, withPackings, expectedDiagnostics, libraryPath, commandLineArgs, language, languageStandard, remappedTypeNames, remappedFieldNames, useHostConfigOnly: true); + } + + private async Task ValidateVariantAsync(BaselineVariant variant, string caseName, string inputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions, string[]? excludedNames, IReadOnlyDictionary? remappedNames, IReadOnlyDictionary? withAccessSpecifiers, IReadOnlyDictionary>? withAttributes, IReadOnlyDictionary? withCallConvs, IReadOnlyDictionary? withClasses, IReadOnlyDictionary? withLibraryPaths, IReadOnlyDictionary? withNamespaces, string[]? withSetLastErrors, IReadOnlyDictionary? withTransparentStructs, IReadOnlyDictionary? withTypes, IReadOnlyDictionary>? withUsings, IReadOnlyDictionary? withPackings, IEnumerable? expectedDiagnostics, string libraryPath, string[]? commandLineArgs, string language, string languageStandard, IReadOnlyDictionary? remappedTypeNames, IReadOnlyDictionary? remappedFieldNames, bool useHostConfigOnly = false) + { + // Host-keyed cases must not add GenerateUnixTypes even when running on a Unix host; the host triple + // already drives the layout difference. All other cases fold the variant's OS into the config exactly + // as the legacy ValidateGenerated{Config}{OS} wrappers did. + var configOptions = (useHostConfigOnly ? BaselineConfig.Latest.ToConfigOptions() : variant.ConfigOptions) | additionalConfigOptions; + + var actual = await GenerateBindingsAsync(inputContents, variant.Mode, configOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, withPackings, expectedDiagnostics, libraryPath, commandLineArgs, language, languageStandard, remappedTypeNames, remappedFieldNames).ConfigureAwait(false); + await BaselineAssertions.AssertOrUpdateAsync(Area, caseName, variant, actual).ConfigureAwait(false); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/ClangSharp.PInvokeGenerator.UnitTests.csproj b/tests/ClangSharp.PInvokeGenerator.UnitTests/ClangSharp.PInvokeGenerator.UnitTests.csproj index b42fed1c..5b1486ec 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/ClangSharp.PInvokeGenerator.UnitTests.csproj +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/ClangSharp.PInvokeGenerator.UnitTests.csproj @@ -18,6 +18,15 @@ + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs index bbe1019b..e7890764 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/PInvokeGeneratorTest.cs @@ -88,6 +88,14 @@ protected static Task ValidateGeneratedXmlCompatibleUnixBindingsAsync(string inp => ValidateGeneratedBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorOutputMode.Xml, PInvokeGeneratorConfigurationOptions.GenerateCompatibleCode | PInvokeGeneratorConfigurationOptions.GenerateUnixTypes | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, withPackings, expectedDiagnostics, libraryPath, commandLineArgs, language, languageStandard); private static async Task ValidateGeneratedBindingsAsync(string inputContents, string expectedOutputContents, PInvokeGeneratorOutputMode outputMode, PInvokeGeneratorConfigurationOptions configOptions, string[]? excludedNames, IReadOnlyDictionary? remappedNames, IReadOnlyDictionary? withAccessSpecifiers, IReadOnlyDictionary>? withAttributes, IReadOnlyDictionary? withCallConvs, IReadOnlyDictionary? withClasses, IReadOnlyDictionary? withLibraryPaths, IReadOnlyDictionary? withNamespaces, string[]? withSetLastErrors, IReadOnlyDictionary? withTransparentStructs, IReadOnlyDictionary? withTypes, IReadOnlyDictionary>? withUsings, IReadOnlyDictionary? withPackings, IEnumerable? expectedDiagnostics, string libraryPath, string[]? commandLineArgs, string language, string languageStandard, IReadOnlyDictionary? remappedTypeNames = null, IReadOnlyDictionary? remappedFieldNames = null) + { + var actualOutputContents = await GenerateBindingsAsync(inputContents, outputMode, configOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, withPackings, expectedDiagnostics, libraryPath, commandLineArgs, language, languageStandard, remappedTypeNames, remappedFieldNames).ConfigureAwait(false); + Assert.That(actualOutputContents, Is.EqualTo(expectedOutputContents)); + } + + // Shared generator core: produces the actual generated bindings text without asserting against an + // expected value, so both the inline-string harness and the checked-in baseline harness can reuse it. + internal static async Task GenerateBindingsAsync(string inputContents, PInvokeGeneratorOutputMode outputMode, PInvokeGeneratorConfigurationOptions configOptions, string[]? excludedNames, IReadOnlyDictionary? remappedNames, IReadOnlyDictionary? withAccessSpecifiers, IReadOnlyDictionary>? withAttributes, IReadOnlyDictionary? withCallConvs, IReadOnlyDictionary? withClasses, IReadOnlyDictionary? withLibraryPaths, IReadOnlyDictionary? withNamespaces, string[]? withSetLastErrors, IReadOnlyDictionary? withTransparentStructs, IReadOnlyDictionary? withTypes, IReadOnlyDictionary>? withUsings, IReadOnlyDictionary? withPackings, IEnumerable? expectedDiagnostics, string libraryPath, string[]? commandLineArgs, string language, string languageStandard, IReadOnlyDictionary? remappedTypeNames = null, IReadOnlyDictionary? remappedFieldNames = null) { Assert.That(DefaultInputFileName, Does.Exist); commandLineArgs ??= DefaultCppClangCommandLineArgs; @@ -146,6 +154,6 @@ private static async Task ValidateGeneratedBindingsAsync(string inputContents, s using var streamReader = new StreamReader(outputStream); var actualOutputContents = await streamReader.ReadToEndAsync().ConfigureAwait(false); - Assert.That(actualOutputContents, Is.EqualTo(expectedOutputContents)); + return actualOutputContents; } } From 8b6bc2b82e687cbb349c79524034db63026edaf5 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Mon, 13 Jul 2026 12:43:06 -0700 Subject: [PATCH 2/3] Migrate the matrix generator fixtures to the baseline harness Replace the 16-way config-folder duplication -- an abstract Base/*Test.cs plus one re-implementation per CSharp/Xml x Default/Latest/Preview/Compatible x Windows/Unix folder, each re-declaring the same C/C++ input and an inline escaped expected string -- with a single fixture per area parameterized over all 16 variants and backed by checked-in baseline files. Each area is now one BaselineTest-derived fixture that supplies the input once; the expected output for every variant lives in a baseline file, deduped across variants by the harness fallback chain. This preserves coverage exactly: the baselines were extracted byte-for-byte from the old inline strings, and variants that previously shared output now share one file. Two latent drift bugs in the old matrix are corrected in passing: several Unix variants asserted stale input that had diverged from their Windows counterparts; the baselines are seeded from the canonical host-independent output instead. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../Base/CXXMethodDeclarationCSharpTest.cs | 614 ----- .../Base/CXXMethodDeclarationTest.cs | 111 - .../Base/CXXMethodDeclarationXmlTest.cs | 676 ------ .../Base/DeprecatedToObsoleteTest.cs | 64 - .../Base/DigitsSeparatorTest.cs | 17 - .../Base/EnumDeclarationTest.cs | 112 - .../Base/FunctionDeclarationBodyImportTest.cs | 288 --- .../Base/FunctionDeclarationDllImportTest.cs | 121 - .../Base/FunctionPointerDeclarationTest.cs | 24 - .../Base/StructDeclarationTest.cs | 312 --- .../Base/UnionDeclarationTest.cs | 245 -- .../Base/VarDeclarationTest.cs | 129 - .../Baseline/BaselineTest.cs | 5 +- .../ConstructorTest.CSharp.cs | 12 + .../ConstructorTest.Xml.xml | 17 + .../ConstructorWithInitializeTest.CSharp.cs | 28 + .../ConstructorWithInitializeTest.Xml.xml | 61 + .../ConversionTest.CSharp.cs | 33 + .../ConversionTest.Xml.xml | 35 + ...FromTemplateTest.CSharp.Compatible.Unix.cs | 11 + ...mTemplateTest.CSharp.Compatible.Windows.cs | 11 + ...tedFromTemplateTest.CSharp.Default.Unix.cs | 11 + ...FromTemplateTest.CSharp.Default.Windows.cs | 11 + ...itedFromTemplateTest.CSharp.Latest.Unix.cs | 11 + ...dFromTemplateTest.CSharp.Latest.Windows.cs | 11 + ...tedFromTemplateTest.CSharp.Preview.Unix.cs | 11 + ...FromTemplateTest.CSharp.Preview.Windows.cs | 11 + ...edFromTemplateTest.Xml.Compatible.Unix.xml | 19 + ...romTemplateTest.Xml.Compatible.Windows.xml | 19 + ...ritedFromTemplateTest.Xml.Default.Unix.xml | 19 + ...edFromTemplateTest.Xml.Default.Windows.xml | 19 + ...eritedFromTemplateTest.Xml.Latest.Unix.xml | 19 + ...tedFromTemplateTest.Xml.Latest.Windows.xml | 19 + ...ritedFromTemplateTest.Xml.Preview.Unix.xml | 19 + ...edFromTemplateTest.Xml.Preview.Windows.xml | 19 + .../DestructorTest.CSharp.cs | 9 + .../DestructorTest.Xml.xml | 11 + .../InstanceTest.CSharp.Compatible.Unix.cs | 20 + .../InstanceTest.CSharp.Default.Unix.cs | 20 + .../InstanceTest.CSharp.Latest.Unix.cs | 20 + .../InstanceTest.CSharp.Preview.Unix.cs | 20 + .../InstanceTest.CSharp.cs | 20 + .../InstanceTest.Xml.Compatible.Unix.xml | 21 + .../InstanceTest.Xml.Default.Unix.xml | 21 + .../InstanceTest.Xml.Latest.Unix.xml | 21 + .../InstanceTest.Xml.Preview.Unix.xml | 21 + .../CXXMethodDeclaration/InstanceTest.Xml.xml | 21 + .../MacrosExpansionTest.CSharp.cs | 19 + .../MacrosExpansionTest.Xml.xml | 23 + .../MemberCallTest.CSharp.cs | 35 + .../MemberCallTest.Xml.xml | 38 + .../CXXMethodDeclaration/MemberTest.CSharp.cs | 12 + .../CXXMethodDeclaration/MemberTest.Xml.xml | 14 + .../NewKeywordTest.CSharp.cs | 75 + .../NewKeywordTest.Xml.xml | 84 + ...ywordVirtualTest.CSharp.Compatible.Unix.cs | 43 + ...rdVirtualTest.CSharp.Compatible.Windows.cs | 43 + ...wKeywordVirtualTest.CSharp.Default.Unix.cs | 24 + ...ywordVirtualTest.CSharp.Default.Windows.cs | 24 + ...ewKeywordVirtualTest.CSharp.Latest.Unix.cs | 24 + ...eywordVirtualTest.CSharp.Latest.Windows.cs | 24 + ...wKeywordVirtualTest.CSharp.Preview.Unix.cs | 24 + ...ywordVirtualTest.CSharp.Preview.Windows.cs | 24 + ...KeywordVirtualTest.Xml.Compatible.Unix.xml | 73 + ...wordVirtualTest.Xml.Compatible.Windows.xml | 73 + ...NewKeywordVirtualTest.Xml.Default.Unix.xml | 37 + ...KeywordVirtualTest.Xml.Default.Windows.xml | 37 + .../NewKeywordVirtualTest.Xml.Latest.Unix.xml | 37 + ...wKeywordVirtualTest.Xml.Latest.Windows.xml | 37 + ...NewKeywordVirtualTest.Xml.Preview.Unix.xml | 37 + ...KeywordVirtualTest.Xml.Preview.Windows.xml | 37 + ...kerInterfaceTest.CSharp.Compatible.Unix.cs | 64 + ...InterfaceTest.CSharp.Compatible.Windows.cs | 64 + ...MarkerInterfaceTest.CSharp.Default.Unix.cs | 46 + ...kerInterfaceTest.CSharp.Default.Windows.cs | 46 + ...dMarkerInterfaceTest.CSharp.Latest.Unix.cs | 46 + ...rkerInterfaceTest.CSharp.Latest.Windows.cs | 46 + ...MarkerInterfaceTest.CSharp.Preview.Unix.cs | 46 + ...kerInterfaceTest.CSharp.Preview.Windows.cs | 46 + ...arkerInterfaceTest.Xml.Compatible.Unix.xml | 104 + ...erInterfaceTest.Xml.Compatible.Windows.xml | 104 + ...ndMarkerInterfaceTest.Xml.Default.Unix.xml | 68 + ...arkerInterfaceTest.Xml.Default.Windows.xml | 68 + ...AndMarkerInterfaceTest.Xml.Latest.Unix.xml | 68 + ...MarkerInterfaceTest.Xml.Latest.Windows.xml | 68 + ...ndMarkerInterfaceTest.Xml.Preview.Unix.xml | 68 + ...arkerInterfaceTest.Xml.Preview.Windows.xml | 68 + ...ExplicitVtblTest.CSharp.Compatible.Unix.cs | 55 + ...licitVtblTest.CSharp.Compatible.Windows.cs | 55 + ...ithExplicitVtblTest.CSharp.Default.Unix.cs | 36 + ...ExplicitVtblTest.CSharp.Default.Windows.cs | 36 + ...WithExplicitVtblTest.CSharp.Latest.Unix.cs | 36 + ...hExplicitVtblTest.CSharp.Latest.Windows.cs | 36 + ...ithExplicitVtblTest.CSharp.Preview.Unix.cs | 36 + ...ExplicitVtblTest.CSharp.Preview.Windows.cs | 36 + ...thExplicitVtblTest.Xml.Compatible.Unix.xml | 84 + ...xplicitVtblTest.Xml.Compatible.Windows.xml | 84 + ...lWithExplicitVtblTest.Xml.Default.Unix.xml | 48 + ...thExplicitVtblTest.Xml.Default.Windows.xml | 48 + ...alWithExplicitVtblTest.Xml.Latest.Unix.xml | 48 + ...ithExplicitVtblTest.Xml.Latest.Windows.xml | 48 + ...lWithExplicitVtblTest.Xml.Preview.Unix.xml | 48 + ...thExplicitVtblTest.Xml.Preview.Windows.xml | 48 + .../OperatorCallTest.CSharp.cs | 35 + .../OperatorCallTest.Xml.xml | 59 + .../OperatorTest.CSharp.cs | 25 + .../CXXMethodDeclaration/OperatorTest.Xml.xml | 39 + .../StaticTest.CSharp.Compatible.Unix.cs | 20 + .../StaticTest.CSharp.Default.Unix.cs | 20 + .../StaticTest.CSharp.Latest.Unix.cs | 20 + .../StaticTest.CSharp.Preview.Unix.cs | 20 + .../CXXMethodDeclaration/StaticTest.CSharp.cs | 20 + .../StaticTest.Xml.Compatible.Unix.xml | 18 + .../StaticTest.Xml.Default.Unix.xml | 18 + .../StaticTest.Xml.Latest.Unix.xml | 18 + .../StaticTest.Xml.Preview.Unix.xml | 18 + .../CXXMethodDeclaration/StaticTest.Xml.xml | 18 + .../CXXMethodDeclaration/ThisTest.CSharp.cs | 12 + .../CXXMethodDeclaration/ThisTest.Xml.xml | 14 + ...UnsafeDoesNotImpactDllImportTest.CSharp.cs | 18 + .../UnsafeDoesNotImpactDllImportTest.Xml.xml | 16 + .../VirtualTest.CSharp.Compatible.cs | 56 + .../VirtualTest.CSharp.Default.cs | 30 + .../VirtualTest.CSharp.Latest.cs | 30 + .../VirtualTest.CSharp.Preview.cs | 30 + .../VirtualTest.Xml.Compatible.xml | 70 + .../VirtualTest.Xml.Default.xml | 34 + .../VirtualTest.Xml.Latest.xml | 34 + .../VirtualTest.Xml.Preview.xml | 34 + ...tblIndexAttributeTest.CSharp.Compatible.cs | 60 + ...thVtblIndexAttributeTest.CSharp.Default.cs | 34 + ...ithVtblIndexAttributeTest.CSharp.Latest.cs | 34 + ...thVtblIndexAttributeTest.CSharp.Preview.cs | 34 + ...hVtblIndexAttributeTest.Xml.Compatible.xml | 70 + ...WithVtblIndexAttributeTest.Xml.Default.xml | 34 + ...lWithVtblIndexAttributeTest.Xml.Latest.xml | 34 + ...WithVtblIndexAttributeTest.Xml.Preview.xml | 34 + .../DeprecatedToObsolete/EnumDecl.CSharp.cs | 26 + .../DeprecatedToObsolete/EnumDecl.Xml.xml | 31 + .../DeprecatedToObsolete/FuncDecl.CSharp.cs | 25 + .../DeprecatedToObsolete/FuncDecl.Xml.xml | 25 + .../FuncDeclDllImport.CSharp.cs | 22 + .../FuncDeclDllImport.Xml.xml | 21 + .../FuncPtrDecl.CSharp.Compatible.cs | 45 + .../FuncPtrDecl.CSharp.Default.cs | 30 + .../FuncPtrDecl.CSharp.Latest.cs | 30 + .../FuncPtrDecl.CSharp.Preview.cs | 30 + .../FuncPtrDecl.Xml.Compatible.xml | 41 + .../FuncPtrDecl.Xml.Default.xml | 27 + .../FuncPtrDecl.Xml.Latest.xml | 27 + .../FuncPtrDecl.Xml.Preview.xml | 27 + .../InstanceFunc.CSharp.cs | 29 + .../DeprecatedToObsolete/InstanceFunc.Xml.xml | 25 + .../SimpleEnumMembers.CSharp.cs | 14 + .../SimpleEnumMembers.Xml.xml | 22 + .../SimpleStructMembers_int_5Fint.CSharp.cs | 17 + .../SimpleStructMembers_int_5Fint.Xml.xml | 21 + ...leTypedefStructMembers_int_5Fint.CSharp.cs | 17 + ...mpleTypedefStructMembers_int_5Fint.Xml.xml | 21 + .../SimpleVarDecl_int_5Fint.CSharp.cs | 17 + .../SimpleVarDecl_int_5Fint.Xml.xml | 33 + .../DeprecatedToObsolete/StructDecl.CSharp.cs | 26 + .../DeprecatedToObsolete/StructDecl.Xml.xml | 27 + .../TypedefStructDecl.CSharp.cs | 26 + .../TypedefStructDecl.Xml.xml | 27 + ...loat_5F1_27024_2E0_5F1_5F024_2E0.CSharp.cs | 8 + ..._float_5F1_27024_2E0_5F1_5F024_2E0.Xml.xml | 13 + ...prTest_float_5F1_27024_5F1_5F024.CSharp.cs | 8 + ...ExprTest_float_5F1_27024_5F1_5F024.Xml.xml | 13 + ..._5F1_27000_27001_5F1_5F000_5F001.CSharp.cs | 8 + ...nt_5F1_27000_27001_5F1_5F000_5F001.Xml.xml | 13 + ...ExprTest_int_5F1_27024_5F1_5F024.CSharp.cs | 8 + ...stExprTest_int_5F1_27024_5F1_5F024.Xml.xml | 13 + .../EnumDeclaration/BasicTest.CSharp.cs | 9 + .../EnumDeclaration/BasicTest.Xml.xml | 17 + .../EnumDeclaration/BasicValueTest.CSharp.cs | 9 + .../EnumDeclaration/BasicValueTest.Xml.xml | 20 + .../EnumDeclaration/ExcludeTest.CSharp.cs | 0 .../EnumDeclaration/ExcludeTest.Xml.xml | 0 .../ExplicitTypedTest_short_5Fshort.CSharp.cs | 9 + .../ExplicitTypedTest_short_5Fshort.Xml.xml | 17 + ...eTypeNameTest_long_20long_5Flong.CSharp.cs | 10 + ...iveTypeNameTest_long_20long_5Flong.Xml.xml | 17 + ...peNameTest_signed_20char_5Fsbyte.CSharp.cs | 10 + ...TypeNameTest_signed_20char_5Fsbyte.Xml.xml | 17 + ...eNameTest_unsigned_20char_5Fbyte.CSharp.cs | 10 + ...ypeNameTest_unsigned_20char_5Fbyte.Xml.xml | 17 + ...peNameTest_unsigned_20int_5Fuint.CSharp.cs | 10 + ...TypeNameTest_unsigned_20int_5Fuint.Xml.xml | 17 + ...t_unsigned_20long_20long_5Fulong.CSharp.cs | 10 + ...est_unsigned_20long_20long_5Fulong.Xml.xml | 17 + ...meTest_unsigned_20short_5Fushort.CSharp.cs | 10 + ...NameTest_unsigned_20short_5Fushort.Xml.xml | 17 + .../EnumDeclaration/RemapTest.CSharp.cs | 30 + .../EnumDeclaration/RemapTest.Xml.xml | 53 + ...nonymousEnumTest.CSharp.Compatible.Unix.cs | 14 + ...ymousEnumTest.CSharp.Compatible.Windows.cs | 14 + ...thAnonymousEnumTest.CSharp.Default.Unix.cs | 14 + ...nonymousEnumTest.CSharp.Default.Windows.cs | 14 + ...ithAnonymousEnumTest.CSharp.Latest.Unix.cs | 14 + ...AnonymousEnumTest.CSharp.Latest.Windows.cs | 14 + ...thAnonymousEnumTest.CSharp.Preview.Unix.cs | 14 + ...nonymousEnumTest.CSharp.Preview.Windows.cs | 14 + ...hAnonymousEnumTest.Xml.Compatible.Unix.xml | 22 + ...onymousEnumTest.Xml.Compatible.Windows.xml | 22 + ...WithAnonymousEnumTest.Xml.Default.Unix.xml | 22 + ...hAnonymousEnumTest.Xml.Default.Windows.xml | 22 + .../WithAnonymousEnumTest.Xml.Latest.Unix.xml | 22 + ...thAnonymousEnumTest.Xml.Latest.Windows.xml | 22 + ...WithAnonymousEnumTest.Xml.Preview.Unix.xml | 22 + ...hAnonymousEnumTest.Xml.Preview.Windows.xml | 22 + .../WithAttributeTest.CSharp.cs | 15 + .../EnumDeclaration/WithAttributeTest.Xml.xml | 24 + .../WithCastToEnumType.CSharp.cs | 9 + .../WithCastToEnumType.Xml.xml | 26 + .../WithImplicitConversionTest.CSharp.cs | 9 + .../WithImplicitConversionTest.Xml.xml | 27 + .../WithMultipleEnumsTest.CSharp.cs | 15 + .../WithMultipleEnumsTest.Xml.xml | 29 + .../WithNamespaceStarPlusTest.CSharp.cs | 15 + .../WithNamespaceStarPlusTest.Xml.xml | 23 + .../WithNamespaceStarTest.CSharp.cs | 14 + .../WithNamespaceStarTest.Xml.xml | 23 + .../WithNamespaceTest.CSharp.cs | 14 + .../EnumDeclaration/WithNamespaceTest.Xml.xml | 23 + ...umEnumeratorTest.CSharp.Compatible.Unix.cs | 10 + ...numeratorTest.CSharp.Compatible.Windows.cs | 10 + ...sEnumEnumeratorTest.CSharp.Default.Unix.cs | 10 + ...umEnumeratorTest.CSharp.Default.Windows.cs | 10 + ...usEnumEnumeratorTest.CSharp.Latest.Unix.cs | 10 + ...numEnumeratorTest.CSharp.Latest.Windows.cs | 10 + ...sEnumEnumeratorTest.CSharp.Preview.Unix.cs | 10 + ...umEnumeratorTest.CSharp.Preview.Windows.cs | 10 + ...EnumEnumeratorTest.Xml.Compatible.Unix.xml | 19 + ...mEnumeratorTest.Xml.Compatible.Windows.xml | 19 + ...ousEnumEnumeratorTest.Xml.Default.Unix.xml | 19 + ...EnumEnumeratorTest.Xml.Default.Windows.xml | 19 + ...mousEnumEnumeratorTest.Xml.Latest.Unix.xml | 19 + ...sEnumEnumeratorTest.Xml.Latest.Windows.xml | 19 + ...ousEnumEnumeratorTest.Xml.Preview.Unix.xml | 19 + ...EnumEnumeratorTest.Xml.Preview.Windows.xml | 19 + ...ithTypeAndImplicitConversionTest.CSharp.cs | 10 + .../WithTypeAndImplicitConversionTest.Xml.xml | 20 + .../WithTypeStarOverrideTest.CSharp.cs | 13 + .../WithTypeStarOverrideTest.Xml.xml | 17 + .../WithTypeStarTest.CSharp.cs | 14 + .../EnumDeclaration/WithTypeStarTest.Xml.xml | 17 + .../EnumDeclaration/WithTypeTest.CSharp.cs | 10 + .../EnumDeclaration/WithTypeTest.Xml.xml | 17 + ...AccessUnionMemberTest.CSharp.Compatible.cs | 38 + .../AccessUnionMemberTest.CSharp.Default.cs | 37 + .../AccessUnionMemberTest.CSharp.Latest.cs | 37 + .../AccessUnionMemberTest.CSharp.Preview.cs | 37 + .../AccessUnionMemberTest.Xml.Compatible.xml | 32 + .../AccessUnionMemberTest.Xml.Default.xml | 29 + .../AccessUnionMemberTest.Xml.Latest.xml | 29 + .../AccessUnionMemberTest.Xml.Preview.xml | 29 + .../ArraySubscriptTest.CSharp.cs | 10 + .../ArraySubscriptTest.Xml.xml | 17 + .../BasicTest.CSharp.cs | 9 + .../BasicTest.Xml.xml | 11 + .../BinaryOperatorBasicTest__25.CSharp.cs | 10 + .../BinaryOperatorBasicTest__25.Xml.xml | 17 + .../BinaryOperatorBasicTest__25_3D.CSharp.cs | 10 + .../BinaryOperatorBasicTest__25_3D.Xml.xml | 17 + .../BinaryOperatorBasicTest__26.CSharp.cs | 10 + .../BinaryOperatorBasicTest__26.Xml.xml | 17 + .../BinaryOperatorBasicTest__26_3D.CSharp.cs | 10 + .../BinaryOperatorBasicTest__26_3D.Xml.xml | 17 + .../BinaryOperatorBasicTest__2A.CSharp.cs | 10 + .../BinaryOperatorBasicTest__2A.Xml.xml | 17 + .../BinaryOperatorBasicTest__2A_3D.CSharp.cs | 10 + .../BinaryOperatorBasicTest__2A_3D.Xml.xml | 17 + .../BinaryOperatorBasicTest__2B.CSharp.cs | 10 + .../BinaryOperatorBasicTest__2B.Xml.xml | 17 + .../BinaryOperatorBasicTest__2B_3D.CSharp.cs | 10 + .../BinaryOperatorBasicTest__2B_3D.Xml.xml | 17 + .../BinaryOperatorBasicTest__2D.CSharp.cs | 10 + .../BinaryOperatorBasicTest__2D.Xml.xml | 17 + .../BinaryOperatorBasicTest__2D_3D.CSharp.cs | 10 + .../BinaryOperatorBasicTest__2D_3D.Xml.xml | 17 + .../BinaryOperatorBasicTest__2F.CSharp.cs | 10 + .../BinaryOperatorBasicTest__2F.Xml.xml | 17 + .../BinaryOperatorBasicTest__2F_3D.CSharp.cs | 10 + .../BinaryOperatorBasicTest__2F_3D.Xml.xml | 17 + .../BinaryOperatorBasicTest__3C_3C.CSharp.cs | 10 + .../BinaryOperatorBasicTest__3C_3C.Xml.xml | 17 + ...inaryOperatorBasicTest__3C_3C_3D.CSharp.cs | 10 + .../BinaryOperatorBasicTest__3C_3C_3D.Xml.xml | 17 + .../BinaryOperatorBasicTest__3D.CSharp.cs | 10 + .../BinaryOperatorBasicTest__3D.Xml.xml | 17 + .../BinaryOperatorBasicTest__3E_3E.CSharp.cs | 10 + .../BinaryOperatorBasicTest__3E_3E.Xml.xml | 17 + ...inaryOperatorBasicTest__3E_3E_3D.CSharp.cs | 10 + .../BinaryOperatorBasicTest__3E_3E_3D.Xml.xml | 17 + .../BinaryOperatorBasicTest__5E.CSharp.cs | 10 + .../BinaryOperatorBasicTest__5E.Xml.xml | 17 + .../BinaryOperatorBasicTest__5E_3D.CSharp.cs | 10 + .../BinaryOperatorBasicTest__5E_3D.Xml.xml | 17 + .../BinaryOperatorBasicTest__7C.CSharp.cs | 10 + .../BinaryOperatorBasicTest__7C.Xml.xml | 17 + .../BinaryOperatorBasicTest__7C_3D.CSharp.cs | 10 + .../BinaryOperatorBasicTest__7C_3D.Xml.xml | 17 + ...BinaryOperatorBooleanTest__26_26.CSharp.cs | 10 + .../BinaryOperatorBooleanTest__26_26.Xml.xml | 17 + ...BinaryOperatorBooleanTest__7C_7C.CSharp.cs | 10 + .../BinaryOperatorBooleanTest__7C_7C.Xml.xml | 17 + ...BinaryOperatorCompareTest__21_3D.CSharp.cs | 10 + .../BinaryOperatorCompareTest__21_3D.Xml.xml | 17 + .../BinaryOperatorCompareTest__3C.CSharp.cs | 10 + .../BinaryOperatorCompareTest__3C.Xml.xml | 17 + ...BinaryOperatorCompareTest__3C_3D.CSharp.cs | 10 + .../BinaryOperatorCompareTest__3C_3D.Xml.xml | 17 + ...BinaryOperatorCompareTest__3D_3D.CSharp.cs | 10 + .../BinaryOperatorCompareTest__3D_3D.Xml.xml | 17 + .../BinaryOperatorCompareTest__3E.CSharp.cs | 10 + .../BinaryOperatorCompareTest__3E.Xml.xml | 17 + ...BinaryOperatorCompareTest__3E_3D.CSharp.cs | 10 + .../BinaryOperatorCompareTest__3E_3D.Xml.xml | 17 + .../BreakTest.CSharp.cs | 15 + .../BreakTest.Xml.xml | 19 + .../CStyleFunctionalCastTest.CSharp.cs | 10 + .../CStyleFunctionalCastTest.Xml.xml | 14 + .../CallFunctionTest.CSharp.cs | 14 + .../CallFunctionTest.Xml.xml | 15 + .../CallFunctionWithArgsTest.CSharp.cs | 14 + .../CallFunctionWithArgsTest.Xml.xml | 21 + .../CaseNoCompoundTest.CSharp.cs | 24 + .../CaseNoCompoundTest.Xml.xml | 28 + .../CaseTest.CSharp.cs | 24 + .../CaseTest.Xml.xml | 28 + .../CompareMultipleEnumTest.CSharp.cs | 19 + .../CompareMultipleEnumTest.Xml.xml | 26 + .../ConditionalOperatorTest.CSharp.cs | 10 + .../ConditionalOperatorTest.Xml.xml | 20 + .../ContinueTest.CSharp.cs | 15 + .../ContinueTest.Xml.xml | 19 + .../CxxConstCastTest.CSharp.cs | 10 + .../CxxConstCastTest.Xml.xml | 14 + .../CxxDynamicCastTest.CSharp.Compatible.cs | 46 + .../CxxDynamicCastTest.CSharp.Default.cs | 33 + .../CxxDynamicCastTest.CSharp.Latest.cs | 33 + .../CxxDynamicCastTest.CSharp.Preview.cs | 33 + .../CxxDynamicCastTest.Xml.Compatible.xml | 54 + .../CxxDynamicCastTest.Xml.Default.xml | 36 + .../CxxDynamicCastTest.Xml.Latest.xml | 36 + .../CxxDynamicCastTest.Xml.Preview.xml | 36 + .../CxxFunctionalCastTest.CSharp.cs | 10 + .../CxxFunctionalCastTest.Xml.xml | 14 + .../CxxReinterpretCastTest.CSharp.cs | 10 + .../CxxReinterpretCastTest.Xml.xml | 14 + .../CxxStaticCastTest.CSharp.cs | 10 + .../CxxStaticCastTest.Xml.xml | 14 + .../DeclTest.CSharp.cs | 13 + .../DeclTest.Xml.xml | 14 + .../DoNonCompoundTest.CSharp.cs | 17 + .../DoNonCompoundTest.Xml.xml | 21 + .../DoTest.CSharp.cs | 18 + .../DoTest.Xml.xml | 22 + .../ForNonCompoundTest.CSharp.cs | 67 + .../ForNonCompoundTest.Xml.xml | 71 + .../ForTest.CSharp.cs | 67 + .../ForTest.Xml.xml | 71 + .../IfElseIfTest.CSharp.cs | 19 + .../IfElseIfTest.Xml.xml | 35 + .../IfElseNonCompoundTest.CSharp.cs | 17 + .../IfElseNonCompoundTest.Xml.xml | 27 + .../IfElseTest.CSharp.cs | 17 + .../IfElseTest.Xml.xml | 27 + .../IfTest.CSharp.cs | 15 + .../IfTest.Xml.xml | 25 + .../InitListForArrayTest.CSharp.cs | 28 + .../InitListForArrayTest.Xml.xml | 29 + .../InitListForRecordDeclTest.CSharp.cs | 37 + .../InitListForRecordDeclTest.Xml.xml | 40 + .../MemberTest.CSharp.cs | 20 + .../MemberTest.Xml.xml | 26 + .../RefToPtrTest.CSharp.cs | 15 + .../RefToPtrTest.Xml.xml | 22 + ...eturnCXXBooleanLiteralTest_false.CSharp.cs | 10 + .../ReturnCXXBooleanLiteralTest_false.Xml.xml | 11 + ...ReturnCXXBooleanLiteralTest_true.CSharp.cs | 10 + .../ReturnCXXBooleanLiteralTest_true.Xml.xml | 11 + .../ReturnCXXNullPtrTest.CSharp.cs | 10 + .../ReturnCXXNullPtrTest.Xml.xml | 11 + .../ReturnEmptyTest.CSharp.cs | 10 + .../ReturnEmptyTest.Xml.xml | 11 + ...FloatingLiteralDoubleTest_3_2E14.CSharp.cs | 10 + ...rnFloatingLiteralDoubleTest_3_2E14.Xml.xml | 11 + ...FloatingLiteralDoubleTest_5e_2D1.CSharp.cs | 10 + ...rnFloatingLiteralDoubleTest_5e_2D1.Xml.xml | 11 + ...loatingLiteralSingleTest_3_2E14f.CSharp.cs | 10 + ...nFloatingLiteralSingleTest_3_2E14f.Xml.xml | 11 + ...loatingLiteralSingleTest_5e_2D1f.CSharp.cs | 10 + ...nFloatingLiteralSingleTest_5e_2D1f.Xml.xml | 11 + .../ReturnIntegerLiteralInt32Test.CSharp.cs | 10 + .../ReturnIntegerLiteralInt32Test.Xml.xml | 11 + .../ReturnStructTest.CSharp.cs | 21 + .../ReturnStructTest.Xml.xml | 24 + .../SwitchNonCompoundTest.CSharp.cs | 24 + .../SwitchNonCompoundTest.Xml.xml | 28 + .../SwitchTest.CSharp.cs | 16 + .../SwitchTest.Xml.xml | 20 + .../UnaryOperatorAddrOfTest.CSharp.cs | 10 + .../UnaryOperatorAddrOfTest.Xml.xml | 14 + .../UnaryOperatorDerefTest.CSharp.cs | 10 + .../UnaryOperatorDerefTest.Xml.xml | 14 + .../UnaryOperatorLogicalNotTest.CSharp.cs | 10 + .../UnaryOperatorLogicalNotTest.Xml.xml | 14 + .../UnaryOperatorPostfixTest__2B_2B.CSharp.cs | 10 + .../UnaryOperatorPostfixTest__2B_2B.Xml.xml | 14 + .../UnaryOperatorPostfixTest__2D_2D.CSharp.cs | 10 + .../UnaryOperatorPostfixTest__2D_2D.Xml.xml | 14 + .../UnaryOperatorPrefixTest__2B.CSharp.cs | 10 + .../UnaryOperatorPrefixTest__2B.Xml.xml | 14 + .../UnaryOperatorPrefixTest__2B_2B.CSharp.cs | 10 + .../UnaryOperatorPrefixTest__2B_2B.Xml.xml | 14 + .../UnaryOperatorPrefixTest__2D.CSharp.cs | 10 + .../UnaryOperatorPrefixTest__2D.Xml.xml | 14 + .../UnaryOperatorPrefixTest__2D_2D.CSharp.cs | 10 + .../UnaryOperatorPrefixTest__2D_2D.Xml.xml | 14 + .../UnaryOperatorPrefixTest__7E.CSharp.cs | 10 + .../UnaryOperatorPrefixTest__7E.Xml.xml | 14 + .../WhileNonCompoundTest.CSharp.cs | 17 + .../WhileNonCompoundTest.Xml.xml | 21 + .../WhileTest.CSharp.cs | 17 + .../WhileTest.Xml.xml | 21 + .../ArrayParameterTest.CSharp.cs | 10 + .../ArrayParameterTest.Xml.xml | 13 + .../BasicTest.CSharp.cs | 10 + .../BasicTest.Xml.xml | 10 + ...nPointerParameterTest.CSharp.Compatible.cs | 11 + ...tionPointerParameterTest.CSharp.Default.cs | 10 + ...ctionPointerParameterTest.CSharp.Latest.cs | 10 + ...tionPointerParameterTest.CSharp.Preview.cs | 10 + ...ionPointerParameterTest.Xml.Compatible.xml | 13 + ...nctionPointerParameterTest.Xml.Default.xml | 13 + ...unctionPointerParameterTest.Xml.Latest.xml | 13 + ...nctionPointerParameterTest.Xml.Preview.xml | 13 + .../IntrinsicsTest.CSharp.cs | 0 .../IntrinsicsTest.Xml.xml | 0 .../NamespaceTest.CSharp.Compatible.Unix.cs | 10 + .../NamespaceTest.CSharp.Default.Unix.cs | 10 + .../NamespaceTest.CSharp.Latest.Unix.cs | 10 + .../NamespaceTest.CSharp.Preview.Unix.cs | 10 + .../NamespaceTest.CSharp.cs | 10 + .../NamespaceTest.Xml.Compatible.Unix.xml | 10 + .../NamespaceTest.Xml.Default.Unix.xml | 10 + .../NamespaceTest.Xml.Latest.Unix.xml | 10 + .../NamespaceTest.Xml.Preview.Unix.xml | 10 + .../NamespaceTest.Xml.xml | 10 + .../NoLibraryPathTest.CSharp.cs | 10 + .../NoLibraryPathTest.Xml.xml | 10 + ...5F1_2E0_5FFalse_5Fdouble_5F1_2E0.CSharp.cs | 10 + ...e_5F1_2E0_5FFalse_5Fdouble_5F1_2E0.Xml.xml | 16 + ...F6_2E0f_5FFalse_5Ffloat_5F6_2E0f.CSharp.cs | 10 + ..._5F6_2E0f_5FFalse_5Ffloat_5F6_2E0f.Xml.xml | 16 + ...erTest_int_5F3_5FFalse_5Fint_5F3.CSharp.cs | 10 + ...eterTest_int_5F3_5FFalse_5Fint_5F3.Xml.xml | 16 + ...ong_20long_5F4_5FTrue_5Flong_5F4.CSharp.cs | 10 + ..._long_20long_5F4_5FTrue_5Flong_5F4.Xml.xml | 16 + ...st_short_5F2_5FFalse_5Fshort_5F2.CSharp.cs | 10 + ...Test_short_5F2_5FFalse_5Fshort_5F2.Xml.xml | 16 + ...ed_20char_5F5_5FTrue_5Fsbyte_5F5.CSharp.cs | 10 + ...gned_20char_5F5_5FTrue_5Fsbyte_5F5.Xml.xml | 16 + ...ned_20char_5F0_5FTrue_5Fbyte_5F0.CSharp.cs | 10 + ...igned_20char_5F0_5FTrue_5Fbyte_5F0.Xml.xml | 16 + ...gned_20int_5F8_5FTrue_5Fuint_5F8.CSharp.cs | 10 + ...signed_20int_5F8_5FTrue_5Fuint_5F8.Xml.xml | 16 + ...ng_20long_5F9_5FTrue_5Fulong_5F9.CSharp.cs | 10 + ...long_20long_5F9_5FTrue_5Fulong_5F9.Xml.xml | 16 + ..._20short_5F7_5FTrue_5Fushort_5F7.CSharp.cs | 10 + ...ed_20short_5F7_5FTrue_5Fushort_5F7.Xml.xml | 16 + ...ushort_5F_28byte_29_28_27A_27_29.CSharp.cs | 10 + ...5Fushort_5F_28byte_29_28_27A_27_29.Xml.xml | 16 + ..._void_20_2A_5F0_5Fvoid_2A_5Fnull.CSharp.cs | 10 + ...st_void_20_2A_5F0_5Fvoid_2A_5Fnull.Xml.xml | 16 + ...20_2A_5Fnullptr_5Fvoid_2A_5Fnull.CSharp.cs | 10 + ...d_20_2A_5Fnullptr_5Fvoid_2A_5Fnull.Xml.xml | 16 + .../SourceLocationTest.CSharp.cs | 11 + .../SourceLocationTest.Xml.xml | 13 + .../TemplateMemberTest.CSharp.cs | 10 + .../TemplateMemberTest.Xml.xml | 10 + ...ameterTest_bool_5FTrue_5Fbyte_5F.CSharp.cs | 10 + ...arameterTest_bool_5FTrue_5Fbyte_5F.Xml.xml | 13 + ..._5FIntPtr_5Fusing_20System_3B_0A.CSharp.cs | 11 + ...ue_5FIntPtr_5Fusing_20System_3B_0A.Xml.xml | 13 + ...rameterTest_int_5FFalse_5Fint_5F.CSharp.cs | 10 + ...ParameterTest_int_5FFalse_5Fint_5F.Xml.xml | 13 + ..._5FIntPtr_5Fusing_20System_3B_0A.CSharp.cs | 11 + ...ue_5FIntPtr_5Fusing_20System_3B_0A.Xml.xml | 13 + .../VarargsTest.CSharp.Compatible.Windows.cs | 10 + .../VarargsTest.CSharp.Default.Windows.cs | 10 + .../VarargsTest.CSharp.Latest.Windows.cs | 10 + .../VarargsTest.CSharp.Preview.Windows.cs | 10 + .../WithCallConvStarOverrideTest.CSharp.cs | 13 + .../WithCallConvStarOverrideTest.Xml.xml | 19 + .../WithCallConvStarTest.CSharp.cs | 13 + .../WithCallConvStarTest.Xml.xml | 19 + .../WithCallConvTest.CSharp.cs | 13 + .../WithCallConvTest.Xml.xml | 19 + .../WithLibraryPathStarTest.CSharp.cs | 10 + .../WithLibraryPathStarTest.Xml.xml | 10 + .../WithLibraryPathTest.CSharp.cs | 10 + .../WithLibraryPathTest.Xml.xml | 10 + .../WithSetLastErrorStarTest.CSharp.cs | 13 + .../WithSetLastErrorStarTest.Xml.xml | 19 + .../WithSetLastErrorTest.CSharp.cs | 13 + .../WithSetLastErrorTest.Xml.xml | 19 + .../BasicTest.CSharp.Compatible.cs | 14 + .../BasicTest.CSharp.Default.cs | 8 + .../BasicTest.CSharp.Latest.cs | 8 + .../BasicTest.CSharp.Preview.cs | 8 + .../BasicTest.Xml.Compatible.xml | 13 + .../BasicTest.Xml.Default.xml | 10 + .../BasicTest.Xml.Latest.xml | 10 + .../BasicTest.Xml.Preview.xml | 10 + .../CallconvTest.CSharp.Compatible.cs | 14 + .../CallconvTest.CSharp.Default.cs | 8 + .../CallconvTest.CSharp.Latest.cs | 8 + .../CallconvTest.CSharp.Preview.cs | 8 + .../CallconvTest.Xml.Compatible.xml | 13 + .../CallconvTest.Xml.Default.xml | 10 + .../CallconvTest.Xml.Latest.xml | 10 + .../CallconvTest.Xml.Preview.xml | 10 + ...ointerlessTypedefTest.CSharp.Compatible.cs | 14 + .../PointerlessTypedefTest.CSharp.Default.cs | 8 + .../PointerlessTypedefTest.CSharp.Latest.cs | 8 + .../PointerlessTypedefTest.CSharp.Preview.cs | 8 + .../PointerlessTypedefTest.Xml.Compatible.xml | 13 + .../PointerlessTypedefTest.Xml.Default.xml | 10 + .../PointerlessTypedefTest.Xml.Latest.xml | 10 + .../PointerlessTypedefTest.Xml.Preview.xml | 10 + ...uctAndAnonStructArray.CSharp.Compatible.cs | 49 + ...StructAndAnonStructArray.CSharp.Default.cs | 39 + ...nStructAndAnonStructArray.CSharp.Latest.cs | 39 + ...StructAndAnonStructArray.CSharp.Preview.cs | 39 + ...tructAndAnonStructArray.Xml.Compatible.xml | 52 + ...onStructAndAnonStructArray.Xml.Default.xml | 35 + ...nonStructAndAnonStructArray.Xml.Latest.xml | 35 + ...onStructAndAnonStructArray.Xml.Preview.xml | 35 + ...BasicTestInCMode_double_5Fdouble.CSharp.cs | 11 + .../BasicTestInCMode_double_5Fdouble.Xml.xml | 16 + .../BasicTestInCMode_float_5Ffloat.CSharp.cs | 11 + .../BasicTestInCMode_float_5Ffloat.Xml.xml | 16 + .../BasicTestInCMode_int_5Fint.CSharp.cs | 11 + .../BasicTestInCMode_int_5Fint.Xml.xml | 16 + .../BasicTestInCMode_short_5Fshort.CSharp.cs | 11 + .../BasicTestInCMode_short_5Fshort.Xml.xml | 16 + .../BasicTest_double_5Fdouble.CSharp.cs | 11 + .../BasicTest_double_5Fdouble.Xml.xml | 16 + .../BasicTest_float_5Ffloat.CSharp.cs | 11 + .../BasicTest_float_5Ffloat.Xml.xml | 16 + .../BasicTest_int_5Fint.CSharp.cs | 11 + .../BasicTest_int_5Fint.Xml.xml | 16 + .../BasicTest_short_5Fshort.CSharp.cs | 11 + .../BasicTest_short_5Fshort.Xml.xml | 16 + ...thNativeTypeNameTest_bool_5Fbyte.CSharp.cs | 14 + ...WithNativeTypeNameTest_bool_5Fbyte.Xml.xml | 16 + ...eTypeNameTest_long_20long_5Flong.CSharp.cs | 14 + ...iveTypeNameTest_long_20long_5Flong.Xml.xml | 16 + ...peNameTest_signed_20char_5Fsbyte.CSharp.cs | 14 + ...TypeNameTest_signed_20char_5Fsbyte.Xml.xml | 16 + ...eNameTest_unsigned_20char_5Fbyte.CSharp.cs | 14 + ...ypeNameTest_unsigned_20char_5Fbyte.Xml.xml | 16 + ...peNameTest_unsigned_20int_5Fuint.CSharp.cs | 14 + ...TypeNameTest_unsigned_20int_5Fuint.Xml.xml | 16 + ...t_unsigned_20long_20long_5Fulong.CSharp.cs | 14 + ...est_unsigned_20long_20long_5Fulong.Xml.xml | 16 + ...meTest_unsigned_20short_5Fushort.CSharp.cs | 14 + ...NameTest_unsigned_20short_5Fushort.Xml.xml | 16 + .../BitfieldTest.CSharp.Compatible.Unix.cs | 177 ++ .../BitfieldTest.CSharp.Compatible.Windows.cs | 181 ++ .../BitfieldTest.CSharp.Default.Unix.cs | 177 ++ .../BitfieldTest.CSharp.Default.Windows.cs | 181 ++ .../BitfieldTest.CSharp.Latest.Unix.cs | 177 ++ .../BitfieldTest.CSharp.Latest.Windows.cs | 181 ++ .../BitfieldTest.CSharp.Preview.Unix.cs | 177 ++ .../BitfieldTest.CSharp.Preview.Windows.cs | 181 ++ .../BitfieldTest.Xml.Compatible.Unix.xml | 139 ++ .../BitfieldTest.Xml.Compatible.Windows.xml | 145 ++ .../BitfieldTest.Xml.Default.Unix.xml | 139 ++ .../BitfieldTest.Xml.Default.Windows.xml | 145 ++ .../BitfieldTest.Xml.Latest.Unix.xml | 139 ++ .../BitfieldTest.Xml.Latest.Windows.xml | 145 ++ .../BitfieldTest.Xml.Preview.Unix.xml | 139 ++ .../BitfieldTest.Xml.Preview.Windows.xml | 145 ++ ...eldAttributeTest.CSharp.Compatible.Unix.cs | 188 ++ ...AttributeTest.CSharp.Compatible.Windows.cs | 192 ++ ...tfieldAttributeTest.CSharp.Default.Unix.cs | 188 ++ ...eldAttributeTest.CSharp.Default.Windows.cs | 192 ++ ...itfieldAttributeTest.CSharp.Latest.Unix.cs | 188 ++ ...ieldAttributeTest.CSharp.Latest.Windows.cs | 192 ++ ...tfieldAttributeTest.CSharp.Preview.Unix.cs | 188 ++ ...eldAttributeTest.CSharp.Preview.Windows.cs | 192 ++ ...fieldAttributeTest.Xml.Compatible.Unix.xml | 150 ++ ...ldAttributeTest.Xml.Compatible.Windows.xml | 156 ++ ...BitfieldAttributeTest.Xml.Default.Unix.xml | 150 ++ ...fieldAttributeTest.Xml.Default.Windows.xml | 156 ++ ...eBitfieldAttributeTest.Xml.Latest.Unix.xml | 150 ++ ...tfieldAttributeTest.Xml.Latest.Windows.xml | 156 ++ ...BitfieldAttributeTest.Xml.Preview.Unix.xml | 150 ++ ...fieldAttributeTest.Xml.Preview.Windows.xml | 156 ++ .../DeclTypeTest.CSharp.Compatible.cs | 17 + .../DeclTypeTest.CSharp.Default.cs | 16 + .../DeclTypeTest.CSharp.Latest.cs | 16 + .../DeclTypeTest.CSharp.Preview.cs | 16 + .../DeclTypeTest.Xml.Compatible.xml | 15 + .../DeclTypeTest.Xml.Default.xml | 15 + .../DeclTypeTest.Xml.Latest.xml | 15 + .../DeclTypeTest.Xml.Preview.xml | 15 + ...eplyNestedAnonStructs.CSharp.Compatible.cs | 55 + .../DeeplyNestedAnonStructs.CSharp.Default.cs | 53 + .../DeeplyNestedAnonStructs.CSharp.Latest.cs | 53 + .../DeeplyNestedAnonStructs.CSharp.Preview.cs | 53 + ...DeeplyNestedAnonStructs.Xml.Compatible.xml | 51 + .../DeeplyNestedAnonStructs.Xml.Default.xml | 45 + .../DeeplyNestedAnonStructs.Xml.Latest.xml | 45 + .../DeeplyNestedAnonStructs.Xml.Preview.xml | 45 + .../StructDeclaration/ExcludeTest.CSharp.cs | 0 .../StructDeclaration/ExcludeTest.Xml.xml | 0 ...lTest_double_5Fdouble.CSharp.Compatible.cs | 63 + ...onalTest_double_5Fdouble.CSharp.Default.cs | 21 + ...ionalTest_double_5Fdouble.CSharp.Latest.cs | 21 + ...onalTest_double_5Fdouble.CSharp.Preview.cs | 21 + ...nalTest_double_5Fdouble.Xml.Compatible.xml | 101 + ...sionalTest_double_5Fdouble.Xml.Default.xml | 21 + ...nsionalTest_double_5Fdouble.Xml.Latest.xml | 21 + ...sionalTest_double_5Fdouble.Xml.Preview.xml | 21 + ...nalTest_float_5Ffloat.CSharp.Compatible.cs | 63 + ...sionalTest_float_5Ffloat.CSharp.Default.cs | 21 + ...nsionalTest_float_5Ffloat.CSharp.Latest.cs | 21 + ...sionalTest_float_5Ffloat.CSharp.Preview.cs | 21 + ...ionalTest_float_5Ffloat.Xml.Compatible.xml | 101 + ...ensionalTest_float_5Ffloat.Xml.Default.xml | 21 + ...mensionalTest_float_5Ffloat.Xml.Latest.xml | 21 + ...ensionalTest_float_5Ffloat.Xml.Preview.xml | 21 + ...nsionalTest_int_5Fint.CSharp.Compatible.cs | 63 + ...imensionalTest_int_5Fint.CSharp.Default.cs | 21 + ...dimensionalTest_int_5Fint.CSharp.Latest.cs | 21 + ...imensionalTest_int_5Fint.CSharp.Preview.cs | 21 + ...mensionalTest_int_5Fint.Xml.Compatible.xml | 101 + ...idimensionalTest_int_5Fint.Xml.Default.xml | 21 + ...tidimensionalTest_int_5Fint.Xml.Latest.xml | 21 + ...idimensionalTest_int_5Fint.Xml.Preview.xml | 21 + ...nalTest_short_5Fshort.CSharp.Compatible.cs | 63 + ...sionalTest_short_5Fshort.CSharp.Default.cs | 21 + ...nsionalTest_short_5Fshort.CSharp.Latest.cs | 21 + ...sionalTest_short_5Fshort.CSharp.Preview.cs | 21 + ...ionalTest_short_5Fshort.Xml.Compatible.xml | 101 + ...ensionalTest_short_5Fshort.Xml.Default.xml | 21 + ...mensionalTest_short_5Fshort.Xml.Latest.xml | 21 + ...ensionalTest_short_5Fshort.Xml.Preview.xml | 21 + ...eTest_double_5Fdouble.CSharp.Compatible.cs | 31 + ...tiveTest_double_5Fdouble.CSharp.Default.cs | 21 + ...itiveTest_double_5Fdouble.CSharp.Latest.cs | 21 + ...tiveTest_double_5Fdouble.CSharp.Preview.cs | 21 + ...iveTest_double_5Fdouble.Xml.Compatible.xml | 38 + ...mitiveTest_double_5Fdouble.Xml.Default.xml | 21 + ...imitiveTest_double_5Fdouble.Xml.Latest.xml | 21 + ...mitiveTest_double_5Fdouble.Xml.Preview.xml | 21 + ...iveTest_float_5Ffloat.CSharp.Compatible.cs | 31 + ...mitiveTest_float_5Ffloat.CSharp.Default.cs | 21 + ...imitiveTest_float_5Ffloat.CSharp.Latest.cs | 21 + ...mitiveTest_float_5Ffloat.CSharp.Preview.cs | 21 + ...itiveTest_float_5Ffloat.Xml.Compatible.xml | 38 + ...rimitiveTest_float_5Ffloat.Xml.Default.xml | 21 + ...PrimitiveTest_float_5Ffloat.Xml.Latest.xml | 21 + ...rimitiveTest_float_5Ffloat.Xml.Preview.xml | 21 + ...imitiveTest_int_5Fint.CSharp.Compatible.cs | 31 + ...nPrimitiveTest_int_5Fint.CSharp.Default.cs | 21 + ...onPrimitiveTest_int_5Fint.CSharp.Latest.cs | 21 + ...nPrimitiveTest_int_5Fint.CSharp.Preview.cs | 21 + ...PrimitiveTest_int_5Fint.Xml.Compatible.xml | 38 + ...NonPrimitiveTest_int_5Fint.Xml.Default.xml | 21 + ...rNonPrimitiveTest_int_5Fint.Xml.Latest.xml | 21 + ...NonPrimitiveTest_int_5Fint.Xml.Preview.xml | 21 + ...iveTest_short_5Fshort.CSharp.Compatible.cs | 31 + ...mitiveTest_short_5Fshort.CSharp.Default.cs | 21 + ...imitiveTest_short_5Fshort.CSharp.Latest.cs | 21 + ...mitiveTest_short_5Fshort.CSharp.Preview.cs | 21 + ...itiveTest_short_5Fshort.Xml.Compatible.xml | 38 + ...rimitiveTest_short_5Fshort.Xml.Default.xml | 21 + ...PrimitiveTest_short_5Fshort.Xml.Latest.xml | 21 + ...rimitiveTest_short_5Fshort.Xml.Preview.xml | 21 + ...fTest_double_5Fdouble.CSharp.Compatible.cs | 31 + ...edefTest_double_5Fdouble.CSharp.Default.cs | 21 + ...pedefTest_double_5Fdouble.CSharp.Latest.cs | 21 + ...edefTest_double_5Fdouble.CSharp.Preview.cs | 21 + ...defTest_double_5Fdouble.Xml.Compatible.xml | 38 + ...ypedefTest_double_5Fdouble.Xml.Default.xml | 21 + ...TypedefTest_double_5Fdouble.Xml.Latest.xml | 21 + ...ypedefTest_double_5Fdouble.Xml.Preview.xml | 21 + ...defTest_float_5Ffloat.CSharp.Compatible.cs | 31 + ...ypedefTest_float_5Ffloat.CSharp.Default.cs | 21 + ...TypedefTest_float_5Ffloat.CSharp.Latest.cs | 21 + ...ypedefTest_float_5Ffloat.CSharp.Preview.cs | 21 + ...pedefTest_float_5Ffloat.Xml.Compatible.xml | 38 + ...eTypedefTest_float_5Ffloat.Xml.Default.xml | 21 + ...veTypedefTest_float_5Ffloat.Xml.Latest.xml | 21 + ...eTypedefTest_float_5Ffloat.Xml.Preview.xml | 21 + ...TypedefTest_int_5Fint.CSharp.Compatible.cs | 31 + ...iveTypedefTest_int_5Fint.CSharp.Default.cs | 21 + ...tiveTypedefTest_int_5Fint.CSharp.Latest.cs | 21 + ...iveTypedefTest_int_5Fint.CSharp.Preview.cs | 21 + ...veTypedefTest_int_5Fint.Xml.Compatible.xml | 38 + ...itiveTypedefTest_int_5Fint.Xml.Default.xml | 21 + ...mitiveTypedefTest_int_5Fint.Xml.Latest.xml | 21 + ...itiveTypedefTest_int_5Fint.Xml.Preview.xml | 21 + ...defTest_short_5Fshort.CSharp.Compatible.cs | 31 + ...ypedefTest_short_5Fshort.CSharp.Default.cs | 21 + ...TypedefTest_short_5Fshort.CSharp.Latest.cs | 21 + ...ypedefTest_short_5Fshort.CSharp.Preview.cs | 21 + ...pedefTest_short_5Fshort.Xml.Compatible.xml | 38 + ...eTypedefTest_short_5Fshort.Xml.Default.xml | 21 + ...veTypedefTest_short_5Fshort.Xml.Latest.xml | 21 + ...eTypedefTest_short_5Fshort.Xml.Preview.xml | 21 + ...eNameTest_bool_5Fbyte.CSharp.Compatible.cs | 32 + ...TypeNameTest_bool_5Fbyte.CSharp.Default.cs | 22 + ...eTypeNameTest_bool_5Fbyte.CSharp.Latest.cs | 22 + ...TypeNameTest_bool_5Fbyte.CSharp.Preview.cs | 22 + ...ypeNameTest_bool_5Fbyte.Xml.Compatible.xml | 38 + ...veTypeNameTest_bool_5Fbyte.Xml.Default.xml | 21 + ...iveTypeNameTest_bool_5Fbyte.Xml.Latest.xml | 21 + ...veTypeNameTest_bool_5Fbyte.Xml.Preview.xml | 21 + ...st_long_20long_5Flong.CSharp.Compatible.cs | 32 + ...eTest_long_20long_5Flong.CSharp.Default.cs | 22 + ...meTest_long_20long_5Flong.CSharp.Latest.cs | 22 + ...eTest_long_20long_5Flong.CSharp.Preview.cs | 22 + ...Test_long_20long_5Flong.Xml.Compatible.xml | 38 + ...ameTest_long_20long_5Flong.Xml.Default.xml | 21 + ...NameTest_long_20long_5Flong.Xml.Latest.xml | 21 + ...ameTest_long_20long_5Flong.Xml.Preview.xml | 21 + ...signed_20char_5Fsbyte.CSharp.Compatible.cs | 32 + ...st_signed_20char_5Fsbyte.CSharp.Default.cs | 22 + ...est_signed_20char_5Fsbyte.CSharp.Latest.cs | 22 + ...st_signed_20char_5Fsbyte.CSharp.Preview.cs | 22 + ...t_signed_20char_5Fsbyte.Xml.Compatible.xml | 38 + ...Test_signed_20char_5Fsbyte.Xml.Default.xml | 21 + ...eTest_signed_20char_5Fsbyte.Xml.Latest.xml | 21 + ...Test_signed_20char_5Fsbyte.Xml.Preview.xml | 21 + ...nsigned_20char_5Fbyte.CSharp.Compatible.cs | 32 + ...t_unsigned_20char_5Fbyte.CSharp.Default.cs | 22 + ...st_unsigned_20char_5Fbyte.CSharp.Latest.cs | 22 + ...t_unsigned_20char_5Fbyte.CSharp.Preview.cs | 22 + ..._unsigned_20char_5Fbyte.Xml.Compatible.xml | 38 + ...est_unsigned_20char_5Fbyte.Xml.Default.xml | 21 + ...Test_unsigned_20char_5Fbyte.Xml.Latest.xml | 21 + ...est_unsigned_20char_5Fbyte.Xml.Preview.xml | 21 + ...unsigned_20int_5Fuint.CSharp.Compatible.cs | 32 + ...st_unsigned_20int_5Fuint.CSharp.Default.cs | 22 + ...est_unsigned_20int_5Fuint.CSharp.Latest.cs | 22 + ...st_unsigned_20int_5Fuint.CSharp.Preview.cs | 22 + ...t_unsigned_20int_5Fuint.Xml.Compatible.xml | 38 + ...Test_unsigned_20int_5Fuint.Xml.Default.xml | 21 + ...eTest_unsigned_20int_5Fuint.Xml.Latest.xml | 21 + ...Test_unsigned_20int_5Fuint.Xml.Preview.xml | 21 + ...20long_20long_5Fulong.CSharp.Compatible.cs | 32 + ...ed_20long_20long_5Fulong.CSharp.Default.cs | 22 + ...ned_20long_20long_5Fulong.CSharp.Latest.cs | 22 + ...ed_20long_20long_5Fulong.CSharp.Preview.cs | 22 + ...d_20long_20long_5Fulong.Xml.Compatible.xml | 38 + ...gned_20long_20long_5Fulong.Xml.Default.xml | 21 + ...igned_20long_20long_5Fulong.Xml.Latest.xml | 21 + ...gned_20long_20long_5Fulong.Xml.Preview.xml | 21 + ...gned_20short_5Fushort.CSharp.Compatible.cs | 32 + ...nsigned_20short_5Fushort.CSharp.Default.cs | 22 + ...unsigned_20short_5Fushort.CSharp.Latest.cs | 22 + ...nsigned_20short_5Fushort.CSharp.Preview.cs | 22 + ...signed_20short_5Fushort.Xml.Compatible.xml | 38 + ..._unsigned_20short_5Fushort.Xml.Default.xml | 21 + ...t_unsigned_20short_5Fushort.Xml.Latest.xml | 21 + ..._unsigned_20short_5Fushort.Xml.Preview.xml | 21 + ...terTest_double_20_2A_5Fdouble_2A.CSharp.cs | 26 + ...interTest_double_20_2A_5Fdouble_2A.Xml.xml | 33 + ...interTest_float_20_2A_5Ffloat_2A.CSharp.cs | 26 + ...PointerTest_float_20_2A_5Ffloat_2A.Xml.xml | 33 + ...erPointerTest_int_20_2A_5Fint_2A.CSharp.cs | 26 + ...fferPointerTest_int_20_2A_5Fint_2A.Xml.xml | 33 + ...interTest_short_20_2A_5Fshort_2A.CSharp.cs | 26 + ...PointerTest_short_20_2A_5Fshort_2A.Xml.xml | 33 + ...lTest_double_5Fdouble.CSharp.Compatible.cs | 8 + ...onalTest_double_5Fdouble.CSharp.Default.cs | 16 + ...ionalTest_double_5Fdouble.CSharp.Latest.cs | 16 + ...onalTest_double_5Fdouble.CSharp.Preview.cs | 16 + ...nalTest_double_5Fdouble.Xml.Compatible.xml | 10 + ...sionalTest_double_5Fdouble.Xml.Default.xml | 16 + ...nsionalTest_double_5Fdouble.Xml.Latest.xml | 16 + ...sionalTest_double_5Fdouble.Xml.Preview.xml | 16 + ...nalTest_float_5Ffloat.CSharp.Compatible.cs | 8 + ...sionalTest_float_5Ffloat.CSharp.Default.cs | 16 + ...nsionalTest_float_5Ffloat.CSharp.Latest.cs | 16 + ...sionalTest_float_5Ffloat.CSharp.Preview.cs | 16 + ...ionalTest_float_5Ffloat.Xml.Compatible.xml | 10 + ...ensionalTest_float_5Ffloat.Xml.Default.xml | 16 + ...mensionalTest_float_5Ffloat.Xml.Latest.xml | 16 + ...ensionalTest_float_5Ffloat.Xml.Preview.xml | 16 + ...nsionalTest_int_5Fint.CSharp.Compatible.cs | 8 + ...imensionalTest_int_5Fint.CSharp.Default.cs | 16 + ...dimensionalTest_int_5Fint.CSharp.Latest.cs | 16 + ...imensionalTest_int_5Fint.CSharp.Preview.cs | 16 + ...mensionalTest_int_5Fint.Xml.Compatible.xml | 10 + ...idimensionalTest_int_5Fint.Xml.Default.xml | 16 + ...tidimensionalTest_int_5Fint.Xml.Latest.xml | 16 + ...idimensionalTest_int_5Fint.Xml.Preview.xml | 16 + ...st_long_20long_5Flong.CSharp.Compatible.cs | 8 + ...lTest_long_20long_5Flong.CSharp.Default.cs | 16 + ...alTest_long_20long_5Flong.CSharp.Latest.cs | 16 + ...lTest_long_20long_5Flong.CSharp.Preview.cs | 16 + ...Test_long_20long_5Flong.Xml.Compatible.xml | 10 + ...nalTest_long_20long_5Flong.Xml.Default.xml | 16 + ...onalTest_long_20long_5Flong.Xml.Latest.xml | 16 + ...nalTest_long_20long_5Flong.Xml.Preview.xml | 16 + ...nalTest_short_5Fshort.CSharp.Compatible.cs | 8 + ...sionalTest_short_5Fshort.CSharp.Default.cs | 16 + ...nsionalTest_short_5Fshort.CSharp.Latest.cs | 16 + ...sionalTest_short_5Fshort.CSharp.Preview.cs | 16 + ...ionalTest_short_5Fshort.Xml.Compatible.xml | 10 + ...ensionalTest_short_5Fshort.Xml.Default.xml | 16 + ...mensionalTest_short_5Fshort.Xml.Latest.xml | 16 + ...ensionalTest_short_5Fshort.Xml.Preview.xml | 16 + ...signed_20char_5Fsbyte.CSharp.Compatible.cs | 8 + ...st_signed_20char_5Fsbyte.CSharp.Default.cs | 16 + ...est_signed_20char_5Fsbyte.CSharp.Latest.cs | 16 + ...st_signed_20char_5Fsbyte.CSharp.Preview.cs | 16 + ...t_signed_20char_5Fsbyte.Xml.Compatible.xml | 10 + ...Test_signed_20char_5Fsbyte.Xml.Default.xml | 16 + ...lTest_signed_20char_5Fsbyte.Xml.Latest.xml | 16 + ...Test_signed_20char_5Fsbyte.Xml.Preview.xml | 16 + ...nsigned_20char_5Fbyte.CSharp.Compatible.cs | 8 + ...t_unsigned_20char_5Fbyte.CSharp.Default.cs | 16 + ...st_unsigned_20char_5Fbyte.CSharp.Latest.cs | 16 + ...t_unsigned_20char_5Fbyte.CSharp.Preview.cs | 16 + ..._unsigned_20char_5Fbyte.Xml.Compatible.xml | 10 + ...est_unsigned_20char_5Fbyte.Xml.Default.xml | 16 + ...Test_unsigned_20char_5Fbyte.Xml.Latest.xml | 16 + ...est_unsigned_20char_5Fbyte.Xml.Preview.xml | 16 + ...unsigned_20int_5Fuint.CSharp.Compatible.cs | 8 + ...st_unsigned_20int_5Fuint.CSharp.Default.cs | 16 + ...est_unsigned_20int_5Fuint.CSharp.Latest.cs | 16 + ...st_unsigned_20int_5Fuint.CSharp.Preview.cs | 16 + ...t_unsigned_20int_5Fuint.Xml.Compatible.xml | 10 + ...Test_unsigned_20int_5Fuint.Xml.Default.xml | 16 + ...lTest_unsigned_20int_5Fuint.Xml.Latest.xml | 16 + ...Test_unsigned_20int_5Fuint.Xml.Preview.xml | 16 + ...20long_20long_5Fulong.CSharp.Compatible.cs | 8 + ...ed_20long_20long_5Fulong.CSharp.Default.cs | 16 + ...ned_20long_20long_5Fulong.CSharp.Latest.cs | 16 + ...ed_20long_20long_5Fulong.CSharp.Preview.cs | 16 + ...d_20long_20long_5Fulong.Xml.Compatible.xml | 10 + ...gned_20long_20long_5Fulong.Xml.Default.xml | 16 + ...igned_20long_20long_5Fulong.Xml.Latest.xml | 16 + ...gned_20long_20long_5Fulong.Xml.Preview.xml | 16 + ...gned_20short_5Fushort.CSharp.Compatible.cs | 8 + ...nsigned_20short_5Fushort.CSharp.Default.cs | 16 + ...unsigned_20short_5Fushort.CSharp.Latest.cs | 16 + ...nsigned_20short_5Fushort.CSharp.Preview.cs | 16 + ...signed_20short_5Fushort.Xml.Compatible.xml | 10 + ..._unsigned_20short_5Fushort.Xml.Default.xml | 16 + ...t_unsigned_20short_5Fushort.Xml.Latest.xml | 16 + ..._unsigned_20short_5Fushort.Xml.Preview.xml | 16 + ...eTest_double_5Fdouble.CSharp.Compatible.cs | 8 + ...tiveTest_double_5Fdouble.CSharp.Default.cs | 16 + ...itiveTest_double_5Fdouble.CSharp.Latest.cs | 16 + ...tiveTest_double_5Fdouble.CSharp.Preview.cs | 16 + ...iveTest_double_5Fdouble.Xml.Compatible.xml | 10 + ...mitiveTest_double_5Fdouble.Xml.Default.xml | 16 + ...imitiveTest_double_5Fdouble.Xml.Latest.xml | 16 + ...mitiveTest_double_5Fdouble.Xml.Preview.xml | 16 + ...iveTest_float_5Ffloat.CSharp.Compatible.cs | 8 + ...mitiveTest_float_5Ffloat.CSharp.Default.cs | 16 + ...imitiveTest_float_5Ffloat.CSharp.Latest.cs | 16 + ...mitiveTest_float_5Ffloat.CSharp.Preview.cs | 16 + ...itiveTest_float_5Ffloat.Xml.Compatible.xml | 10 + ...rimitiveTest_float_5Ffloat.Xml.Default.xml | 16 + ...PrimitiveTest_float_5Ffloat.Xml.Latest.xml | 16 + ...rimitiveTest_float_5Ffloat.Xml.Preview.xml | 16 + ...imitiveTest_int_5Fint.CSharp.Compatible.cs | 8 + ...rPrimitiveTest_int_5Fint.CSharp.Default.cs | 16 + ...erPrimitiveTest_int_5Fint.CSharp.Latest.cs | 16 + ...rPrimitiveTest_int_5Fint.CSharp.Preview.cs | 16 + ...PrimitiveTest_int_5Fint.Xml.Compatible.xml | 10 + ...ferPrimitiveTest_int_5Fint.Xml.Default.xml | 16 + ...fferPrimitiveTest_int_5Fint.Xml.Latest.xml | 16 + ...ferPrimitiveTest_int_5Fint.Xml.Preview.xml | 16 + ...st_long_20long_5Flong.CSharp.Compatible.cs | 8 + ...eTest_long_20long_5Flong.CSharp.Default.cs | 16 + ...veTest_long_20long_5Flong.CSharp.Latest.cs | 16 + ...eTest_long_20long_5Flong.CSharp.Preview.cs | 16 + ...Test_long_20long_5Flong.Xml.Compatible.xml | 10 + ...iveTest_long_20long_5Flong.Xml.Default.xml | 16 + ...tiveTest_long_20long_5Flong.Xml.Latest.xml | 16 + ...iveTest_long_20long_5Flong.Xml.Preview.xml | 16 + ...iveTest_short_5Fshort.CSharp.Compatible.cs | 8 + ...mitiveTest_short_5Fshort.CSharp.Default.cs | 16 + ...imitiveTest_short_5Fshort.CSharp.Latest.cs | 16 + ...mitiveTest_short_5Fshort.CSharp.Preview.cs | 16 + ...itiveTest_short_5Fshort.Xml.Compatible.xml | 10 + ...rimitiveTest_short_5Fshort.Xml.Default.xml | 16 + ...PrimitiveTest_short_5Fshort.Xml.Latest.xml | 16 + ...rimitiveTest_short_5Fshort.Xml.Preview.xml | 16 + ...signed_20char_5Fsbyte.CSharp.Compatible.cs | 8 + ...st_signed_20char_5Fsbyte.CSharp.Default.cs | 16 + ...est_signed_20char_5Fsbyte.CSharp.Latest.cs | 16 + ...st_signed_20char_5Fsbyte.CSharp.Preview.cs | 16 + ...t_signed_20char_5Fsbyte.Xml.Compatible.xml | 10 + ...Test_signed_20char_5Fsbyte.Xml.Default.xml | 16 + ...eTest_signed_20char_5Fsbyte.Xml.Latest.xml | 16 + ...Test_signed_20char_5Fsbyte.Xml.Preview.xml | 16 + ...nsigned_20char_5Fbyte.CSharp.Compatible.cs | 8 + ...t_unsigned_20char_5Fbyte.CSharp.Default.cs | 16 + ...st_unsigned_20char_5Fbyte.CSharp.Latest.cs | 16 + ...t_unsigned_20char_5Fbyte.CSharp.Preview.cs | 16 + ..._unsigned_20char_5Fbyte.Xml.Compatible.xml | 10 + ...est_unsigned_20char_5Fbyte.Xml.Default.xml | 16 + ...Test_unsigned_20char_5Fbyte.Xml.Latest.xml | 16 + ...est_unsigned_20char_5Fbyte.Xml.Preview.xml | 16 + ...unsigned_20int_5Fuint.CSharp.Compatible.cs | 8 + ...st_unsigned_20int_5Fuint.CSharp.Default.cs | 16 + ...est_unsigned_20int_5Fuint.CSharp.Latest.cs | 16 + ...st_unsigned_20int_5Fuint.CSharp.Preview.cs | 16 + ...t_unsigned_20int_5Fuint.Xml.Compatible.xml | 10 + ...Test_unsigned_20int_5Fuint.Xml.Default.xml | 16 + ...eTest_unsigned_20int_5Fuint.Xml.Latest.xml | 16 + ...Test_unsigned_20int_5Fuint.Xml.Preview.xml | 16 + ...20long_20long_5Fulong.CSharp.Compatible.cs | 8 + ...ed_20long_20long_5Fulong.CSharp.Default.cs | 16 + ...ned_20long_20long_5Fulong.CSharp.Latest.cs | 16 + ...ed_20long_20long_5Fulong.CSharp.Preview.cs | 16 + ...d_20long_20long_5Fulong.Xml.Compatible.xml | 10 + ...gned_20long_20long_5Fulong.Xml.Default.xml | 16 + ...igned_20long_20long_5Fulong.Xml.Latest.xml | 16 + ...gned_20long_20long_5Fulong.Xml.Preview.xml | 16 + ...gned_20short_5Fushort.CSharp.Compatible.cs | 8 + ...nsigned_20short_5Fushort.CSharp.Default.cs | 16 + ...unsigned_20short_5Fushort.CSharp.Latest.cs | 16 + ...nsigned_20short_5Fushort.CSharp.Preview.cs | 16 + ...signed_20short_5Fushort.Xml.Compatible.xml | 10 + ..._unsigned_20short_5Fushort.Xml.Default.xml | 16 + ...t_unsigned_20short_5Fushort.Xml.Latest.xml | 16 + ..._unsigned_20short_5Fushort.Xml.Preview.xml | 16 + ...fTest_double_5Fdouble.CSharp.Compatible.cs | 8 + ...edefTest_double_5Fdouble.CSharp.Default.cs | 16 + ...pedefTest_double_5Fdouble.CSharp.Latest.cs | 16 + ...edefTest_double_5Fdouble.CSharp.Preview.cs | 16 + ...defTest_double_5Fdouble.Xml.Compatible.xml | 10 + ...ypedefTest_double_5Fdouble.Xml.Default.xml | 16 + ...TypedefTest_double_5Fdouble.Xml.Latest.xml | 16 + ...ypedefTest_double_5Fdouble.Xml.Preview.xml | 16 + ...defTest_float_5Ffloat.CSharp.Compatible.cs | 8 + ...ypedefTest_float_5Ffloat.CSharp.Default.cs | 16 + ...TypedefTest_float_5Ffloat.CSharp.Latest.cs | 16 + ...ypedefTest_float_5Ffloat.CSharp.Preview.cs | 16 + ...pedefTest_float_5Ffloat.Xml.Compatible.xml | 10 + ...eTypedefTest_float_5Ffloat.Xml.Default.xml | 16 + ...veTypedefTest_float_5Ffloat.Xml.Latest.xml | 16 + ...eTypedefTest_float_5Ffloat.Xml.Preview.xml | 16 + ...TypedefTest_int_5Fint.CSharp.Compatible.cs | 8 + ...iveTypedefTest_int_5Fint.CSharp.Default.cs | 16 + ...tiveTypedefTest_int_5Fint.CSharp.Latest.cs | 16 + ...iveTypedefTest_int_5Fint.CSharp.Preview.cs | 16 + ...veTypedefTest_int_5Fint.Xml.Compatible.xml | 10 + ...itiveTypedefTest_int_5Fint.Xml.Default.xml | 16 + ...mitiveTypedefTest_int_5Fint.Xml.Latest.xml | 16 + ...itiveTypedefTest_int_5Fint.Xml.Preview.xml | 16 + ...st_long_20long_5Flong.CSharp.Compatible.cs | 8 + ...fTest_long_20long_5Flong.CSharp.Default.cs | 16 + ...efTest_long_20long_5Flong.CSharp.Latest.cs | 16 + ...fTest_long_20long_5Flong.CSharp.Preview.cs | 16 + ...Test_long_20long_5Flong.Xml.Compatible.xml | 10 + ...defTest_long_20long_5Flong.Xml.Default.xml | 16 + ...edefTest_long_20long_5Flong.Xml.Latest.xml | 16 + ...defTest_long_20long_5Flong.Xml.Preview.xml | 16 + ...defTest_short_5Fshort.CSharp.Compatible.cs | 8 + ...ypedefTest_short_5Fshort.CSharp.Default.cs | 16 + ...TypedefTest_short_5Fshort.CSharp.Latest.cs | 16 + ...ypedefTest_short_5Fshort.CSharp.Preview.cs | 16 + ...pedefTest_short_5Fshort.Xml.Compatible.xml | 10 + ...eTypedefTest_short_5Fshort.Xml.Default.xml | 16 + ...veTypedefTest_short_5Fshort.Xml.Latest.xml | 16 + ...eTypedefTest_short_5Fshort.Xml.Preview.xml | 16 + ...signed_20char_5Fsbyte.CSharp.Compatible.cs | 8 + ...st_signed_20char_5Fsbyte.CSharp.Default.cs | 16 + ...est_signed_20char_5Fsbyte.CSharp.Latest.cs | 16 + ...st_signed_20char_5Fsbyte.CSharp.Preview.cs | 16 + ...t_signed_20char_5Fsbyte.Xml.Compatible.xml | 10 + ...Test_signed_20char_5Fsbyte.Xml.Default.xml | 16 + ...fTest_signed_20char_5Fsbyte.Xml.Latest.xml | 16 + ...Test_signed_20char_5Fsbyte.Xml.Preview.xml | 16 + ...nsigned_20char_5Fbyte.CSharp.Compatible.cs | 8 + ...t_unsigned_20char_5Fbyte.CSharp.Default.cs | 16 + ...st_unsigned_20char_5Fbyte.CSharp.Latest.cs | 16 + ...t_unsigned_20char_5Fbyte.CSharp.Preview.cs | 16 + ..._unsigned_20char_5Fbyte.Xml.Compatible.xml | 10 + ...est_unsigned_20char_5Fbyte.Xml.Default.xml | 16 + ...Test_unsigned_20char_5Fbyte.Xml.Latest.xml | 16 + ...est_unsigned_20char_5Fbyte.Xml.Preview.xml | 16 + ...unsigned_20int_5Fuint.CSharp.Compatible.cs | 8 + ...st_unsigned_20int_5Fuint.CSharp.Default.cs | 16 + ...est_unsigned_20int_5Fuint.CSharp.Latest.cs | 16 + ...st_unsigned_20int_5Fuint.CSharp.Preview.cs | 16 + ...t_unsigned_20int_5Fuint.Xml.Compatible.xml | 10 + ...Test_unsigned_20int_5Fuint.Xml.Default.xml | 16 + ...fTest_unsigned_20int_5Fuint.Xml.Latest.xml | 16 + ...Test_unsigned_20int_5Fuint.Xml.Preview.xml | 16 + ...20long_20long_5Fulong.CSharp.Compatible.cs | 8 + ...ed_20long_20long_5Fulong.CSharp.Default.cs | 16 + ...ned_20long_20long_5Fulong.CSharp.Latest.cs | 16 + ...ed_20long_20long_5Fulong.CSharp.Preview.cs | 16 + ...d_20long_20long_5Fulong.Xml.Compatible.xml | 10 + ...gned_20long_20long_5Fulong.Xml.Default.xml | 16 + ...igned_20long_20long_5Fulong.Xml.Latest.xml | 16 + ...gned_20long_20long_5Fulong.Xml.Preview.xml | 16 + ...gned_20short_5Fushort.CSharp.Compatible.cs | 8 + ...nsigned_20short_5Fushort.CSharp.Default.cs | 16 + ...unsigned_20short_5Fushort.CSharp.Latest.cs | 16 + ...nsigned_20short_5Fushort.CSharp.Preview.cs | 16 + ...signed_20short_5Fushort.Xml.Compatible.xml | 10 + ..._unsigned_20short_5Fushort.Xml.Default.xml | 16 + ...t_unsigned_20short_5Fushort.Xml.Latest.xml | 16 + ..._unsigned_20short_5Fushort.Xml.Preview.xml | 16 + .../StructDeclaration/GuidTest.CSharp.cs | 24 + .../StructDeclaration/GuidTest.Xml.xml | 19 + ...eTest_double_5Fdouble.CSharp.Compatible.cs | 8 + ...SizeTest_double_5Fdouble.CSharp.Default.cs | 30 + ...ySizeTest_double_5Fdouble.CSharp.Latest.cs | 30 + ...SizeTest_double_5Fdouble.CSharp.Preview.cs | 30 + ...izeTest_double_5Fdouble.Xml.Compatible.xml | 10 + ...aySizeTest_double_5Fdouble.Xml.Default.xml | 31 + ...raySizeTest_double_5Fdouble.Xml.Latest.xml | 31 + ...aySizeTest_double_5Fdouble.Xml.Preview.xml | 31 + ...izeTest_float_5Ffloat.CSharp.Compatible.cs | 8 + ...aySizeTest_float_5Ffloat.CSharp.Default.cs | 30 + ...raySizeTest_float_5Ffloat.CSharp.Latest.cs | 30 + ...aySizeTest_float_5Ffloat.CSharp.Preview.cs | 30 + ...ySizeTest_float_5Ffloat.Xml.Compatible.xml | 10 + ...rraySizeTest_float_5Ffloat.Xml.Default.xml | 31 + ...ArraySizeTest_float_5Ffloat.Xml.Latest.xml | 31 + ...rraySizeTest_float_5Ffloat.Xml.Preview.xml | 31 + ...raySizeTest_int_5Fint.CSharp.Compatible.cs | 8 + ...eArraySizeTest_int_5Fint.CSharp.Default.cs | 30 + ...teArraySizeTest_int_5Fint.CSharp.Latest.cs | 30 + ...eArraySizeTest_int_5Fint.CSharp.Preview.cs | 30 + ...ArraySizeTest_int_5Fint.Xml.Compatible.xml | 10 + ...eteArraySizeTest_int_5Fint.Xml.Default.xml | 31 + ...leteArraySizeTest_int_5Fint.Xml.Latest.xml | 31 + ...eteArraySizeTest_int_5Fint.Xml.Preview.xml | 31 + ...izeTest_short_5Fshort.CSharp.Compatible.cs | 8 + ...aySizeTest_short_5Fshort.CSharp.Default.cs | 30 + ...raySizeTest_short_5Fshort.CSharp.Latest.cs | 30 + ...aySizeTest_short_5Fshort.CSharp.Preview.cs | 30 + ...ySizeTest_short_5Fshort.Xml.Compatible.xml | 10 + ...rraySizeTest_short_5Fshort.Xml.Default.xml | 31 + ...ArraySizeTest_short_5Fshort.Xml.Latest.xml | 31 + ...rraySizeTest_short_5Fshort.Xml.Preview.xml | 31 + .../InheritanceTest.CSharp.cs | 28 + .../StructDeclaration/InheritanceTest.Xml.xml | 35 + ...thNativeInheritanceAttributeTest.CSharp.cs | 29 + ...WithNativeInheritanceAttributeTest.Xml.xml | 35 + ...ble_5Fdouble_5F10_5F5.CSharp.Compatible.cs | 175 ++ ...double_5Fdouble_5F10_5F5.CSharp.Default.cs | 155 ++ ..._double_5Fdouble_5F10_5F5.CSharp.Latest.cs | 155 ++ ...double_5Fdouble_5F10_5F5.CSharp.Preview.cs | 155 ++ ...ouble_5Fdouble_5F10_5F5.Xml.Compatible.xml | 165 ++ ...t_double_5Fdouble_5F10_5F5.Xml.Default.xml | 127 + ...st_double_5Fdouble_5F10_5F5.Xml.Latest.xml | 127 + ...t_double_5Fdouble_5F10_5F5.Xml.Preview.xml | 127 + ...loat_5Ffloat_5F10_5F5.CSharp.Compatible.cs | 175 ++ ...t_float_5Ffloat_5F10_5F5.CSharp.Default.cs | 155 ++ ...st_float_5Ffloat_5F10_5F5.CSharp.Latest.cs | 155 ++ ...t_float_5Ffloat_5F10_5F5.CSharp.Preview.cs | 155 ++ ..._float_5Ffloat_5F10_5F5.Xml.Compatible.xml | 165 ++ ...est_float_5Ffloat_5F10_5F5.Xml.Default.xml | 127 + ...Test_float_5Ffloat_5F10_5F5.Xml.Latest.xml | 127 + ...est_float_5Ffloat_5F10_5F5.Xml.Preview.xml | 127 + ...st_int_5Fint_5F10_5F5.CSharp.Compatible.cs | 175 ++ ...sTest_int_5Fint_5F10_5F5.CSharp.Default.cs | 155 ++ ...usTest_int_5Fint_5F10_5F5.CSharp.Latest.cs | 155 ++ ...sTest_int_5Fint_5F10_5F5.CSharp.Preview.cs | 155 ++ ...Test_int_5Fint_5F10_5F5.Xml.Compatible.xml | 165 ++ ...ousTest_int_5Fint_5F10_5F5.Xml.Default.xml | 127 + ...mousTest_int_5Fint_5F10_5F5.Xml.Latest.xml | 127 + ...ousTest_int_5Fint_5F10_5F5.Xml.Preview.xml | 127 + ...hort_5Fshort_5F10_5F5.CSharp.Compatible.cs | 175 ++ ...t_short_5Fshort_5F10_5F5.CSharp.Default.cs | 155 ++ ...st_short_5Fshort_5F10_5F5.CSharp.Latest.cs | 155 ++ ...t_short_5Fshort_5F10_5F5.CSharp.Preview.cs | 155 ++ ..._short_5Fshort_5F10_5F5.Xml.Compatible.xml | 165 ++ ...est_short_5Fshort_5F10_5F5.Xml.Default.xml | 127 + ...Test_short_5Fshort_5F10_5F5.Xml.Latest.xml | 127 + ...est_short_5Fshort_5F10_5F5.Xml.Preview.xml | 127 + ...ymousWithBitfieldTest.CSharp.Compatible.cs | 103 + ...nonymousWithBitfieldTest.CSharp.Default.cs | 101 + ...AnonymousWithBitfieldTest.CSharp.Latest.cs | 101 + ...nonymousWithBitfieldTest.CSharp.Preview.cs | 101 + ...onymousWithBitfieldTest.Xml.Compatible.xml | 88 + ...dAnonymousWithBitfieldTest.Xml.Default.xml | 82 + ...edAnonymousWithBitfieldTest.Xml.Latest.xml | 82 + ...dAnonymousWithBitfieldTest.Xml.Preview.xml | 82 + .../NestedTest_double_5Fdouble.CSharp.cs | 22 + .../NestedTest_double_5Fdouble.Xml.xml | 30 + .../NestedTest_float_5Ffloat.CSharp.cs | 22 + .../NestedTest_float_5Ffloat.Xml.xml | 30 + .../NestedTest_int_5Fint.CSharp.cs | 22 + .../NestedTest_int_5Fint.Xml.xml | 30 + .../NestedTest_short_5Fshort.CSharp.cs | 22 + .../NestedTest_short_5Fshort.Xml.xml | 30 + ...thNativeTypeNameTest_bool_5Fbyte.CSharp.cs | 29 + ...WithNativeTypeNameTest_bool_5Fbyte.Xml.xml | 30 + ...eTypeNameTest_long_20long_5Flong.CSharp.cs | 29 + ...iveTypeNameTest_long_20long_5Flong.Xml.xml | 30 + ...peNameTest_signed_20char_5Fsbyte.CSharp.cs | 29 + ...TypeNameTest_signed_20char_5Fsbyte.Xml.xml | 30 + ...eNameTest_unsigned_20char_5Fbyte.CSharp.cs | 29 + ...ypeNameTest_unsigned_20char_5Fbyte.Xml.xml | 30 + ...peNameTest_unsigned_20int_5Fuint.CSharp.cs | 29 + ...TypeNameTest_unsigned_20int_5Fuint.Xml.xml | 30 + ...t_unsigned_20long_20long_5Fulong.CSharp.cs | 29 + ...est_unsigned_20long_20long_5Fulong.Xml.xml | 30 + ...meTest_unsigned_20short_5Fushort.CSharp.cs | 29 + ...NameTest_unsigned_20short_5Fushort.Xml.xml | 30 + .../NewKeywordTest.CSharp.cs | 19 + .../StructDeclaration/NewKeywordTest.Xml.xml | 28 + .../NoDefinitionTest.CSharp.cs | 6 + .../NoDefinitionTest.Xml.xml | 6 + .../StructDeclaration/PackTest.CSharp.cs | 27 + .../StructDeclaration/PackTest.Xml.xml | 27 + .../PointerToSelfTest.CSharp.cs | 9 + .../PointerToSelfTest.Xml.xml | 13 + .../PointerToSelfViaTypedefTest.CSharp.cs | 10 + .../PointerToSelfViaTypedefTest.Xml.xml | 13 + ...apNestedAnonymousTest.CSharp.Compatible.cs | 30 + ...RemapNestedAnonymousTest.CSharp.Default.cs | 30 + .../RemapNestedAnonymousTest.CSharp.Latest.cs | 30 + ...RemapNestedAnonymousTest.CSharp.Preview.cs | 30 + ...emapNestedAnonymousTest.Xml.Compatible.xml | 33 + .../RemapNestedAnonymousTest.Xml.Default.xml | 30 + .../RemapNestedAnonymousTest.Xml.Latest.xml | 30 + .../RemapNestedAnonymousTest.Xml.Preview.xml | 30 + .../StructDeclaration/RemapTest.CSharp.cs | 6 + .../StructDeclaration/RemapTest.Xml.xml | 6 + .../SkipNonDefinitionPointerTest.CSharp.cs | 6 + .../SkipNonDefinitionPointerTest.Xml.xml | 6 + ...onDefinitionTest_double_5Fdouble.CSharp.cs | 11 + ...pNonDefinitionTest_double_5Fdouble.Xml.xml | 16 + ...pNonDefinitionTest_float_5Ffloat.CSharp.cs | 11 + ...kipNonDefinitionTest_float_5Ffloat.Xml.xml | 16 + .../SkipNonDefinitionTest_int_5Fint.CSharp.cs | 11 + .../SkipNonDefinitionTest_int_5Fint.Xml.xml | 16 + ...pNonDefinitionTest_short_5Fshort.CSharp.cs | 11 + ...kipNonDefinitionTest_short_5Fshort.Xml.xml | 16 + ...thNativeTypeNameTest_bool_5Fbyte.CSharp.cs | 14 + ...WithNativeTypeNameTest_bool_5Fbyte.Xml.xml | 16 + ...eTypeNameTest_long_20long_5Flong.CSharp.cs | 14 + ...iveTypeNameTest_long_20long_5Flong.Xml.xml | 16 + ...peNameTest_signed_20char_5Fsbyte.CSharp.cs | 14 + ...TypeNameTest_signed_20char_5Fsbyte.Xml.xml | 16 + ...eNameTest_unsigned_20char_5Fbyte.CSharp.cs | 14 + ...ypeNameTest_unsigned_20char_5Fbyte.Xml.xml | 16 + ...peNameTest_unsigned_20int_5Fuint.CSharp.cs | 14 + ...TypeNameTest_unsigned_20int_5Fuint.Xml.xml | 16 + ...t_unsigned_20long_20long_5Fulong.CSharp.cs | 14 + ...est_unsigned_20long_20long_5Fulong.Xml.xml | 16 + ...meTest_unsigned_20short_5Fushort.CSharp.cs | 14 + ...NameTest_unsigned_20short_5Fushort.Xml.xml | 16 + .../SourceLocationAttributeTest.CSharp.cs | 15 + .../SourceLocationAttributeTest.Xml.xml | 16 + .../TypedefTest_bool_5Fbyte.CSharp.cs | 14 + .../TypedefTest_bool_5Fbyte.Xml.xml | 16 + .../TypedefTest_double_5Fdouble.CSharp.cs | 14 + .../TypedefTest_double_5Fdouble.Xml.xml | 16 + .../TypedefTest_float_5Ffloat.CSharp.cs | 14 + .../TypedefTest_float_5Ffloat.Xml.xml | 16 + .../TypedefTest_int_5Fint.CSharp.cs | 14 + .../TypedefTest_int_5Fint.Xml.xml | 16 + .../TypedefTest_long_20long_5Flong.CSharp.cs | 14 + .../TypedefTest_long_20long_5Flong.Xml.xml | 16 + .../TypedefTest_short_5Fshort.CSharp.cs | 14 + .../TypedefTest_short_5Fshort.Xml.xml | 16 + ...ypedefTest_signed_20char_5Fsbyte.CSharp.cs | 14 + .../TypedefTest_signed_20char_5Fsbyte.Xml.xml | 16 + ...pedefTest_unsigned_20char_5Fbyte.CSharp.cs | 14 + ...TypedefTest_unsigned_20char_5Fbyte.Xml.xml | 16 + ...ypedefTest_unsigned_20int_5Fuint.CSharp.cs | 14 + .../TypedefTest_unsigned_20int_5Fuint.Xml.xml | 16 + ...t_unsigned_20long_20long_5Fulong.CSharp.cs | 14 + ...est_unsigned_20long_20long_5Fulong.Xml.xml | 16 + ...efTest_unsigned_20short_5Fushort.CSharp.cs | 14 + ...edefTest_unsigned_20short_5Fushort.Xml.xml | 16 + .../UsingDeclarationTest.CSharp.cs | 17 + .../UsingDeclarationTest.Xml.xml | 17 + .../WithAccessSpecifierTest.CSharp.cs | 23 + .../WithAccessSpecifierTest.Xml.xml | 29 + .../WithPackingTest.CSharp.Compatible.cs | 29 + .../WithPackingTest.CSharp.Default.cs | 18 + .../WithPackingTest.CSharp.Latest.cs | 18 + .../WithPackingTest.CSharp.Preview.cs | 18 + .../WithPackingTest.Xml.Compatible.xml | 30 + .../WithPackingTest.Xml.Default.xml | 16 + .../WithPackingTest.Xml.Latest.xml | 16 + .../WithPackingTest.Xml.Preview.xml | 16 + ...BasicTestInCMode_double_5Fdouble.CSharp.cs | 17 + .../BasicTestInCMode_double_5Fdouble.Xml.xml | 16 + .../BasicTestInCMode_float_5Ffloat.CSharp.cs | 17 + .../BasicTestInCMode_float_5Ffloat.Xml.xml | 16 + .../BasicTestInCMode_int_5Fint.CSharp.cs | 17 + .../BasicTestInCMode_int_5Fint.Xml.xml | 16 + .../BasicTestInCMode_short_5Fshort.CSharp.cs | 17 + .../BasicTestInCMode_short_5Fshort.Xml.xml | 16 + .../BasicTest_double_5Fdouble.CSharp.cs | 17 + .../BasicTest_double_5Fdouble.Xml.xml | 16 + .../BasicTest_float_5Ffloat.CSharp.cs | 17 + .../BasicTest_float_5Ffloat.Xml.xml | 16 + .../BasicTest_int_5Fint.CSharp.cs | 17 + .../BasicTest_int_5Fint.Xml.xml | 16 + .../BasicTest_short_5Fshort.CSharp.cs | 17 + .../BasicTest_short_5Fshort.Xml.xml | 16 + ...thNativeTypeNameTest_bool_5Fbyte.CSharp.cs | 20 + ...WithNativeTypeNameTest_bool_5Fbyte.Xml.xml | 16 + ...eTypeNameTest_long_20long_5Flong.CSharp.cs | 20 + ...iveTypeNameTest_long_20long_5Flong.Xml.xml | 16 + ...peNameTest_signed_20char_5Fsbyte.CSharp.cs | 20 + ...TypeNameTest_signed_20char_5Fsbyte.Xml.xml | 16 + ...eNameTest_unsigned_20char_5Fbyte.CSharp.cs | 20 + ...ypeNameTest_unsigned_20char_5Fbyte.Xml.xml | 16 + ...peNameTest_unsigned_20int_5Fuint.CSharp.cs | 20 + ...TypeNameTest_unsigned_20int_5Fuint.Xml.xml | 16 + ...t_unsigned_20long_20long_5Fulong.CSharp.cs | 20 + ...est_unsigned_20long_20long_5Fulong.Xml.xml | 16 + ...meTest_unsigned_20short_5Fushort.CSharp.cs | 20 + ...NameTest_unsigned_20short_5Fushort.Xml.xml | 16 + .../BitfieldTest.CSharp.Compatible.Unix.cs | 188 ++ .../BitfieldTest.CSharp.Compatible.Windows.cs | 194 ++ .../BitfieldTest.CSharp.Default.Unix.cs | 188 ++ .../BitfieldTest.CSharp.Default.Windows.cs | 194 ++ .../BitfieldTest.CSharp.Latest.Unix.cs | 188 ++ .../BitfieldTest.CSharp.Latest.Windows.cs | 194 ++ .../BitfieldTest.CSharp.Preview.Unix.cs | 188 ++ .../BitfieldTest.CSharp.Preview.Windows.cs | 194 ++ .../BitfieldTest.Xml.Compatible.Unix.xml | 139 ++ .../BitfieldTest.Xml.Compatible.Windows.xml | 145 ++ .../BitfieldTest.Xml.Default.Unix.xml | 139 ++ .../BitfieldTest.Xml.Default.Windows.xml | 145 ++ .../BitfieldTest.Xml.Latest.Unix.xml | 139 ++ .../BitfieldTest.Xml.Latest.Windows.xml | 145 ++ .../BitfieldTest.Xml.Preview.Unix.xml | 139 ++ .../BitfieldTest.Xml.Preview.Windows.xml | 145 ++ .../UnionDeclaration/ExcludeTest.CSharp.cs | 0 .../UnionDeclaration/ExcludeTest.Xml.xml | 0 ...lTest_double_5Fdouble.CSharp.Compatible.cs | 69 + ...onalTest_double_5Fdouble.CSharp.Default.cs | 26 + ...ionalTest_double_5Fdouble.CSharp.Latest.cs | 26 + ...onalTest_double_5Fdouble.CSharp.Preview.cs | 26 + ...nalTest_double_5Fdouble.Xml.Compatible.xml | 101 + ...sionalTest_double_5Fdouble.Xml.Default.xml | 21 + ...nsionalTest_double_5Fdouble.Xml.Latest.xml | 21 + ...sionalTest_double_5Fdouble.Xml.Preview.xml | 21 + ...nalTest_float_5Ffloat.CSharp.Compatible.cs | 69 + ...sionalTest_float_5Ffloat.CSharp.Default.cs | 26 + ...nsionalTest_float_5Ffloat.CSharp.Latest.cs | 26 + ...sionalTest_float_5Ffloat.CSharp.Preview.cs | 26 + ...ionalTest_float_5Ffloat.Xml.Compatible.xml | 101 + ...ensionalTest_float_5Ffloat.Xml.Default.xml | 21 + ...mensionalTest_float_5Ffloat.Xml.Latest.xml | 21 + ...ensionalTest_float_5Ffloat.Xml.Preview.xml | 21 + ...nsionalTest_int_5Fint.CSharp.Compatible.cs | 69 + ...imensionalTest_int_5Fint.CSharp.Default.cs | 26 + ...dimensionalTest_int_5Fint.CSharp.Latest.cs | 26 + ...imensionalTest_int_5Fint.CSharp.Preview.cs | 26 + ...mensionalTest_int_5Fint.Xml.Compatible.xml | 101 + ...idimensionalTest_int_5Fint.Xml.Default.xml | 21 + ...tidimensionalTest_int_5Fint.Xml.Latest.xml | 21 + ...idimensionalTest_int_5Fint.Xml.Preview.xml | 21 + ...nalTest_short_5Fshort.CSharp.Compatible.cs | 69 + ...sionalTest_short_5Fshort.CSharp.Default.cs | 26 + ...nsionalTest_short_5Fshort.CSharp.Latest.cs | 26 + ...sionalTest_short_5Fshort.CSharp.Preview.cs | 26 + ...ionalTest_short_5Fshort.Xml.Compatible.xml | 101 + ...ensionalTest_short_5Fshort.Xml.Default.xml | 21 + ...mensionalTest_short_5Fshort.Xml.Latest.xml | 21 + ...ensionalTest_short_5Fshort.Xml.Preview.xml | 21 + ...eTest_double_5Fdouble.CSharp.Compatible.cs | 37 + ...tiveTest_double_5Fdouble.CSharp.Default.cs | 26 + ...itiveTest_double_5Fdouble.CSharp.Latest.cs | 26 + ...tiveTest_double_5Fdouble.CSharp.Preview.cs | 26 + ...iveTest_double_5Fdouble.Xml.Compatible.xml | 38 + ...mitiveTest_double_5Fdouble.Xml.Default.xml | 21 + ...imitiveTest_double_5Fdouble.Xml.Latest.xml | 21 + ...mitiveTest_double_5Fdouble.Xml.Preview.xml | 21 + ...iveTest_float_5Ffloat.CSharp.Compatible.cs | 37 + ...mitiveTest_float_5Ffloat.CSharp.Default.cs | 26 + ...imitiveTest_float_5Ffloat.CSharp.Latest.cs | 26 + ...mitiveTest_float_5Ffloat.CSharp.Preview.cs | 26 + ...itiveTest_float_5Ffloat.Xml.Compatible.xml | 38 + ...rimitiveTest_float_5Ffloat.Xml.Default.xml | 21 + ...PrimitiveTest_float_5Ffloat.Xml.Latest.xml | 21 + ...rimitiveTest_float_5Ffloat.Xml.Preview.xml | 21 + ...imitiveTest_int_5Fint.CSharp.Compatible.cs | 37 + ...nPrimitiveTest_int_5Fint.CSharp.Default.cs | 26 + ...onPrimitiveTest_int_5Fint.CSharp.Latest.cs | 26 + ...nPrimitiveTest_int_5Fint.CSharp.Preview.cs | 26 + ...PrimitiveTest_int_5Fint.Xml.Compatible.xml | 38 + ...NonPrimitiveTest_int_5Fint.Xml.Default.xml | 21 + ...rNonPrimitiveTest_int_5Fint.Xml.Latest.xml | 21 + ...NonPrimitiveTest_int_5Fint.Xml.Preview.xml | 21 + ...iveTest_short_5Fshort.CSharp.Compatible.cs | 37 + ...mitiveTest_short_5Fshort.CSharp.Default.cs | 26 + ...imitiveTest_short_5Fshort.CSharp.Latest.cs | 26 + ...mitiveTest_short_5Fshort.CSharp.Preview.cs | 26 + ...itiveTest_short_5Fshort.Xml.Compatible.xml | 38 + ...rimitiveTest_short_5Fshort.Xml.Default.xml | 21 + ...PrimitiveTest_short_5Fshort.Xml.Latest.xml | 21 + ...rimitiveTest_short_5Fshort.Xml.Preview.xml | 21 + ...fTest_double_5Fdouble.CSharp.Compatible.cs | 37 + ...edefTest_double_5Fdouble.CSharp.Default.cs | 26 + ...pedefTest_double_5Fdouble.CSharp.Latest.cs | 26 + ...edefTest_double_5Fdouble.CSharp.Preview.cs | 26 + ...defTest_double_5Fdouble.Xml.Compatible.xml | 38 + ...ypedefTest_double_5Fdouble.Xml.Default.xml | 21 + ...TypedefTest_double_5Fdouble.Xml.Latest.xml | 21 + ...ypedefTest_double_5Fdouble.Xml.Preview.xml | 21 + ...defTest_float_5Ffloat.CSharp.Compatible.cs | 37 + ...ypedefTest_float_5Ffloat.CSharp.Default.cs | 26 + ...TypedefTest_float_5Ffloat.CSharp.Latest.cs | 26 + ...ypedefTest_float_5Ffloat.CSharp.Preview.cs | 26 + ...pedefTest_float_5Ffloat.Xml.Compatible.xml | 38 + ...eTypedefTest_float_5Ffloat.Xml.Default.xml | 21 + ...veTypedefTest_float_5Ffloat.Xml.Latest.xml | 21 + ...eTypedefTest_float_5Ffloat.Xml.Preview.xml | 21 + ...TypedefTest_int_5Fint.CSharp.Compatible.cs | 37 + ...iveTypedefTest_int_5Fint.CSharp.Default.cs | 26 + ...tiveTypedefTest_int_5Fint.CSharp.Latest.cs | 26 + ...iveTypedefTest_int_5Fint.CSharp.Preview.cs | 26 + ...veTypedefTest_int_5Fint.Xml.Compatible.xml | 38 + ...itiveTypedefTest_int_5Fint.Xml.Default.xml | 21 + ...mitiveTypedefTest_int_5Fint.Xml.Latest.xml | 21 + ...itiveTypedefTest_int_5Fint.Xml.Preview.xml | 21 + ...defTest_short_5Fshort.CSharp.Compatible.cs | 37 + ...ypedefTest_short_5Fshort.CSharp.Default.cs | 26 + ...TypedefTest_short_5Fshort.CSharp.Latest.cs | 26 + ...ypedefTest_short_5Fshort.CSharp.Preview.cs | 26 + ...pedefTest_short_5Fshort.Xml.Compatible.xml | 38 + ...eTypedefTest_short_5Fshort.Xml.Default.xml | 21 + ...veTypedefTest_short_5Fshort.Xml.Latest.xml | 21 + ...eTypedefTest_short_5Fshort.Xml.Preview.xml | 21 + ...eNameTest_bool_5Fbyte.CSharp.Compatible.cs | 38 + ...TypeNameTest_bool_5Fbyte.CSharp.Default.cs | 27 + ...eTypeNameTest_bool_5Fbyte.CSharp.Latest.cs | 27 + ...TypeNameTest_bool_5Fbyte.CSharp.Preview.cs | 27 + ...ypeNameTest_bool_5Fbyte.Xml.Compatible.xml | 38 + ...veTypeNameTest_bool_5Fbyte.Xml.Default.xml | 21 + ...iveTypeNameTest_bool_5Fbyte.Xml.Latest.xml | 21 + ...veTypeNameTest_bool_5Fbyte.Xml.Preview.xml | 21 + ...st_long_20long_5Flong.CSharp.Compatible.cs | 38 + ...eTest_long_20long_5Flong.CSharp.Default.cs | 27 + ...meTest_long_20long_5Flong.CSharp.Latest.cs | 27 + ...eTest_long_20long_5Flong.CSharp.Preview.cs | 27 + ...Test_long_20long_5Flong.Xml.Compatible.xml | 38 + ...ameTest_long_20long_5Flong.Xml.Default.xml | 21 + ...NameTest_long_20long_5Flong.Xml.Latest.xml | 21 + ...ameTest_long_20long_5Flong.Xml.Preview.xml | 21 + ...signed_20char_5Fsbyte.CSharp.Compatible.cs | 38 + ...st_signed_20char_5Fsbyte.CSharp.Default.cs | 27 + ...est_signed_20char_5Fsbyte.CSharp.Latest.cs | 27 + ...st_signed_20char_5Fsbyte.CSharp.Preview.cs | 27 + ...t_signed_20char_5Fsbyte.Xml.Compatible.xml | 38 + ...Test_signed_20char_5Fsbyte.Xml.Default.xml | 21 + ...eTest_signed_20char_5Fsbyte.Xml.Latest.xml | 21 + ...Test_signed_20char_5Fsbyte.Xml.Preview.xml | 21 + ...nsigned_20char_5Fbyte.CSharp.Compatible.cs | 38 + ...t_unsigned_20char_5Fbyte.CSharp.Default.cs | 27 + ...st_unsigned_20char_5Fbyte.CSharp.Latest.cs | 27 + ...t_unsigned_20char_5Fbyte.CSharp.Preview.cs | 27 + ..._unsigned_20char_5Fbyte.Xml.Compatible.xml | 38 + ...est_unsigned_20char_5Fbyte.Xml.Default.xml | 21 + ...Test_unsigned_20char_5Fbyte.Xml.Latest.xml | 21 + ...est_unsigned_20char_5Fbyte.Xml.Preview.xml | 21 + ...unsigned_20int_5Fuint.CSharp.Compatible.cs | 38 + ...st_unsigned_20int_5Fuint.CSharp.Default.cs | 27 + ...est_unsigned_20int_5Fuint.CSharp.Latest.cs | 27 + ...st_unsigned_20int_5Fuint.CSharp.Preview.cs | 27 + ...t_unsigned_20int_5Fuint.Xml.Compatible.xml | 38 + ...Test_unsigned_20int_5Fuint.Xml.Default.xml | 21 + ...eTest_unsigned_20int_5Fuint.Xml.Latest.xml | 21 + ...Test_unsigned_20int_5Fuint.Xml.Preview.xml | 21 + ...20long_20long_5Fulong.CSharp.Compatible.cs | 38 + ...ed_20long_20long_5Fulong.CSharp.Default.cs | 27 + ...ned_20long_20long_5Fulong.CSharp.Latest.cs | 27 + ...ed_20long_20long_5Fulong.CSharp.Preview.cs | 27 + ...d_20long_20long_5Fulong.Xml.Compatible.xml | 38 + ...gned_20long_20long_5Fulong.Xml.Default.xml | 21 + ...igned_20long_20long_5Fulong.Xml.Latest.xml | 21 + ...gned_20long_20long_5Fulong.Xml.Preview.xml | 21 + ...gned_20short_5Fushort.CSharp.Compatible.cs | 38 + ...nsigned_20short_5Fushort.CSharp.Default.cs | 27 + ...unsigned_20short_5Fushort.CSharp.Latest.cs | 27 + ...nsigned_20short_5Fushort.CSharp.Preview.cs | 27 + ...signed_20short_5Fushort.Xml.Compatible.xml | 38 + ..._unsigned_20short_5Fushort.Xml.Default.xml | 21 + ...t_unsigned_20short_5Fushort.Xml.Latest.xml | 21 + ..._unsigned_20short_5Fushort.Xml.Preview.xml | 21 + ...terTest_double_20_2A_5Fdouble_2A.CSharp.cs | 30 + ...interTest_double_20_2A_5Fdouble_2A.Xml.xml | 33 + ...interTest_float_20_2A_5Ffloat_2A.CSharp.cs | 30 + ...PointerTest_float_20_2A_5Ffloat_2A.Xml.xml | 33 + ...erPointerTest_int_20_2A_5Fint_2A.CSharp.cs | 30 + ...fferPointerTest_int_20_2A_5Fint_2A.Xml.xml | 33 + ...interTest_short_20_2A_5Fshort_2A.CSharp.cs | 30 + ...PointerTest_short_20_2A_5Fshort_2A.Xml.xml | 33 + ...lTest_double_5Fdouble.CSharp.Compatible.cs | 12 + ...onalTest_double_5Fdouble.CSharp.Default.cs | 19 + ...ionalTest_double_5Fdouble.CSharp.Latest.cs | 19 + ...onalTest_double_5Fdouble.CSharp.Preview.cs | 19 + ...nalTest_double_5Fdouble.Xml.Compatible.xml | 10 + ...sionalTest_double_5Fdouble.Xml.Default.xml | 16 + ...nsionalTest_double_5Fdouble.Xml.Latest.xml | 16 + ...sionalTest_double_5Fdouble.Xml.Preview.xml | 16 + ...nalTest_float_5Ffloat.CSharp.Compatible.cs | 12 + ...sionalTest_float_5Ffloat.CSharp.Default.cs | 19 + ...nsionalTest_float_5Ffloat.CSharp.Latest.cs | 19 + ...sionalTest_float_5Ffloat.CSharp.Preview.cs | 19 + ...ionalTest_float_5Ffloat.Xml.Compatible.xml | 10 + ...ensionalTest_float_5Ffloat.Xml.Default.xml | 16 + ...mensionalTest_float_5Ffloat.Xml.Latest.xml | 16 + ...ensionalTest_float_5Ffloat.Xml.Preview.xml | 16 + ...nsionalTest_int_5Fint.CSharp.Compatible.cs | 12 + ...imensionalTest_int_5Fint.CSharp.Default.cs | 19 + ...dimensionalTest_int_5Fint.CSharp.Latest.cs | 19 + ...imensionalTest_int_5Fint.CSharp.Preview.cs | 19 + ...mensionalTest_int_5Fint.Xml.Compatible.xml | 10 + ...idimensionalTest_int_5Fint.Xml.Default.xml | 16 + ...tidimensionalTest_int_5Fint.Xml.Latest.xml | 16 + ...idimensionalTest_int_5Fint.Xml.Preview.xml | 16 + ...st_long_20long_5Flong.CSharp.Compatible.cs | 12 + ...lTest_long_20long_5Flong.CSharp.Default.cs | 19 + ...alTest_long_20long_5Flong.CSharp.Latest.cs | 19 + ...lTest_long_20long_5Flong.CSharp.Preview.cs | 19 + ...Test_long_20long_5Flong.Xml.Compatible.xml | 10 + ...nalTest_long_20long_5Flong.Xml.Default.xml | 16 + ...onalTest_long_20long_5Flong.Xml.Latest.xml | 16 + ...nalTest_long_20long_5Flong.Xml.Preview.xml | 16 + ...nalTest_short_5Fshort.CSharp.Compatible.cs | 12 + ...sionalTest_short_5Fshort.CSharp.Default.cs | 19 + ...nsionalTest_short_5Fshort.CSharp.Latest.cs | 19 + ...sionalTest_short_5Fshort.CSharp.Preview.cs | 19 + ...ionalTest_short_5Fshort.Xml.Compatible.xml | 10 + ...ensionalTest_short_5Fshort.Xml.Default.xml | 16 + ...mensionalTest_short_5Fshort.Xml.Latest.xml | 16 + ...ensionalTest_short_5Fshort.Xml.Preview.xml | 16 + ...signed_20char_5Fsbyte.CSharp.Compatible.cs | 12 + ...st_signed_20char_5Fsbyte.CSharp.Default.cs | 19 + ...est_signed_20char_5Fsbyte.CSharp.Latest.cs | 19 + ...st_signed_20char_5Fsbyte.CSharp.Preview.cs | 19 + ...t_signed_20char_5Fsbyte.Xml.Compatible.xml | 10 + ...Test_signed_20char_5Fsbyte.Xml.Default.xml | 16 + ...lTest_signed_20char_5Fsbyte.Xml.Latest.xml | 16 + ...Test_signed_20char_5Fsbyte.Xml.Preview.xml | 16 + ...nsigned_20char_5Fbyte.CSharp.Compatible.cs | 12 + ...t_unsigned_20char_5Fbyte.CSharp.Default.cs | 19 + ...st_unsigned_20char_5Fbyte.CSharp.Latest.cs | 19 + ...t_unsigned_20char_5Fbyte.CSharp.Preview.cs | 19 + ..._unsigned_20char_5Fbyte.Xml.Compatible.xml | 10 + ...est_unsigned_20char_5Fbyte.Xml.Default.xml | 16 + ...Test_unsigned_20char_5Fbyte.Xml.Latest.xml | 16 + ...est_unsigned_20char_5Fbyte.Xml.Preview.xml | 16 + ...unsigned_20int_5Fuint.CSharp.Compatible.cs | 12 + ...st_unsigned_20int_5Fuint.CSharp.Default.cs | 19 + ...est_unsigned_20int_5Fuint.CSharp.Latest.cs | 19 + ...st_unsigned_20int_5Fuint.CSharp.Preview.cs | 19 + ...t_unsigned_20int_5Fuint.Xml.Compatible.xml | 10 + ...Test_unsigned_20int_5Fuint.Xml.Default.xml | 16 + ...lTest_unsigned_20int_5Fuint.Xml.Latest.xml | 16 + ...Test_unsigned_20int_5Fuint.Xml.Preview.xml | 16 + ...20long_20long_5Fulong.CSharp.Compatible.cs | 12 + ...ed_20long_20long_5Fulong.CSharp.Default.cs | 19 + ...ned_20long_20long_5Fulong.CSharp.Latest.cs | 19 + ...ed_20long_20long_5Fulong.CSharp.Preview.cs | 19 + ...d_20long_20long_5Fulong.Xml.Compatible.xml | 10 + ...gned_20long_20long_5Fulong.Xml.Default.xml | 16 + ...igned_20long_20long_5Fulong.Xml.Latest.xml | 16 + ...gned_20long_20long_5Fulong.Xml.Preview.xml | 16 + ...gned_20short_5Fushort.CSharp.Compatible.cs | 12 + ...nsigned_20short_5Fushort.CSharp.Default.cs | 19 + ...unsigned_20short_5Fushort.CSharp.Latest.cs | 19 + ...nsigned_20short_5Fushort.CSharp.Preview.cs | 19 + ...signed_20short_5Fushort.Xml.Compatible.xml | 10 + ..._unsigned_20short_5Fushort.Xml.Default.xml | 16 + ...t_unsigned_20short_5Fushort.Xml.Latest.xml | 16 + ..._unsigned_20short_5Fushort.Xml.Preview.xml | 16 + ...eTest_double_5Fdouble.CSharp.Compatible.cs | 12 + ...tiveTest_double_5Fdouble.CSharp.Default.cs | 19 + ...itiveTest_double_5Fdouble.CSharp.Latest.cs | 19 + ...tiveTest_double_5Fdouble.CSharp.Preview.cs | 19 + ...iveTest_double_5Fdouble.Xml.Compatible.xml | 10 + ...mitiveTest_double_5Fdouble.Xml.Default.xml | 16 + ...imitiveTest_double_5Fdouble.Xml.Latest.xml | 16 + ...mitiveTest_double_5Fdouble.Xml.Preview.xml | 16 + ...iveTest_float_5Ffloat.CSharp.Compatible.cs | 12 + ...mitiveTest_float_5Ffloat.CSharp.Default.cs | 19 + ...imitiveTest_float_5Ffloat.CSharp.Latest.cs | 19 + ...mitiveTest_float_5Ffloat.CSharp.Preview.cs | 19 + ...itiveTest_float_5Ffloat.Xml.Compatible.xml | 10 + ...rimitiveTest_float_5Ffloat.Xml.Default.xml | 16 + ...PrimitiveTest_float_5Ffloat.Xml.Latest.xml | 16 + ...rimitiveTest_float_5Ffloat.Xml.Preview.xml | 16 + ...imitiveTest_int_5Fint.CSharp.Compatible.cs | 12 + ...rPrimitiveTest_int_5Fint.CSharp.Default.cs | 19 + ...erPrimitiveTest_int_5Fint.CSharp.Latest.cs | 19 + ...rPrimitiveTest_int_5Fint.CSharp.Preview.cs | 19 + ...PrimitiveTest_int_5Fint.Xml.Compatible.xml | 10 + ...ferPrimitiveTest_int_5Fint.Xml.Default.xml | 16 + ...fferPrimitiveTest_int_5Fint.Xml.Latest.xml | 16 + ...ferPrimitiveTest_int_5Fint.Xml.Preview.xml | 16 + ...st_long_20long_5Flong.CSharp.Compatible.cs | 12 + ...eTest_long_20long_5Flong.CSharp.Default.cs | 19 + ...veTest_long_20long_5Flong.CSharp.Latest.cs | 19 + ...eTest_long_20long_5Flong.CSharp.Preview.cs | 19 + ...Test_long_20long_5Flong.Xml.Compatible.xml | 10 + ...iveTest_long_20long_5Flong.Xml.Default.xml | 16 + ...tiveTest_long_20long_5Flong.Xml.Latest.xml | 16 + ...iveTest_long_20long_5Flong.Xml.Preview.xml | 16 + ...iveTest_short_5Fshort.CSharp.Compatible.cs | 12 + ...mitiveTest_short_5Fshort.CSharp.Default.cs | 19 + ...imitiveTest_short_5Fshort.CSharp.Latest.cs | 19 + ...mitiveTest_short_5Fshort.CSharp.Preview.cs | 19 + ...itiveTest_short_5Fshort.Xml.Compatible.xml | 10 + ...rimitiveTest_short_5Fshort.Xml.Default.xml | 16 + ...PrimitiveTest_short_5Fshort.Xml.Latest.xml | 16 + ...rimitiveTest_short_5Fshort.Xml.Preview.xml | 16 + ...signed_20char_5Fsbyte.CSharp.Compatible.cs | 12 + ...st_signed_20char_5Fsbyte.CSharp.Default.cs | 19 + ...est_signed_20char_5Fsbyte.CSharp.Latest.cs | 19 + ...st_signed_20char_5Fsbyte.CSharp.Preview.cs | 19 + ...t_signed_20char_5Fsbyte.Xml.Compatible.xml | 10 + ...Test_signed_20char_5Fsbyte.Xml.Default.xml | 16 + ...eTest_signed_20char_5Fsbyte.Xml.Latest.xml | 16 + ...Test_signed_20char_5Fsbyte.Xml.Preview.xml | 16 + ...nsigned_20char_5Fbyte.CSharp.Compatible.cs | 12 + ...t_unsigned_20char_5Fbyte.CSharp.Default.cs | 19 + ...st_unsigned_20char_5Fbyte.CSharp.Latest.cs | 19 + ...t_unsigned_20char_5Fbyte.CSharp.Preview.cs | 19 + ..._unsigned_20char_5Fbyte.Xml.Compatible.xml | 10 + ...est_unsigned_20char_5Fbyte.Xml.Default.xml | 16 + ...Test_unsigned_20char_5Fbyte.Xml.Latest.xml | 16 + ...est_unsigned_20char_5Fbyte.Xml.Preview.xml | 16 + ...unsigned_20int_5Fuint.CSharp.Compatible.cs | 12 + ...st_unsigned_20int_5Fuint.CSharp.Default.cs | 19 + ...est_unsigned_20int_5Fuint.CSharp.Latest.cs | 19 + ...st_unsigned_20int_5Fuint.CSharp.Preview.cs | 19 + ...t_unsigned_20int_5Fuint.Xml.Compatible.xml | 10 + ...Test_unsigned_20int_5Fuint.Xml.Default.xml | 16 + ...eTest_unsigned_20int_5Fuint.Xml.Latest.xml | 16 + ...Test_unsigned_20int_5Fuint.Xml.Preview.xml | 16 + ...20long_20long_5Fulong.CSharp.Compatible.cs | 12 + ...ed_20long_20long_5Fulong.CSharp.Default.cs | 19 + ...ned_20long_20long_5Fulong.CSharp.Latest.cs | 19 + ...ed_20long_20long_5Fulong.CSharp.Preview.cs | 19 + ...d_20long_20long_5Fulong.Xml.Compatible.xml | 10 + ...gned_20long_20long_5Fulong.Xml.Default.xml | 16 + ...igned_20long_20long_5Fulong.Xml.Latest.xml | 16 + ...gned_20long_20long_5Fulong.Xml.Preview.xml | 16 + ...gned_20short_5Fushort.CSharp.Compatible.cs | 12 + ...nsigned_20short_5Fushort.CSharp.Default.cs | 19 + ...unsigned_20short_5Fushort.CSharp.Latest.cs | 19 + ...nsigned_20short_5Fushort.CSharp.Preview.cs | 19 + ...signed_20short_5Fushort.Xml.Compatible.xml | 10 + ..._unsigned_20short_5Fushort.Xml.Default.xml | 16 + ...t_unsigned_20short_5Fushort.Xml.Latest.xml | 16 + ..._unsigned_20short_5Fushort.Xml.Preview.xml | 16 + ...fTest_double_5Fdouble.CSharp.Compatible.cs | 12 + ...edefTest_double_5Fdouble.CSharp.Default.cs | 19 + ...pedefTest_double_5Fdouble.CSharp.Latest.cs | 19 + ...edefTest_double_5Fdouble.CSharp.Preview.cs | 19 + ...defTest_double_5Fdouble.Xml.Compatible.xml | 10 + ...ypedefTest_double_5Fdouble.Xml.Default.xml | 16 + ...TypedefTest_double_5Fdouble.Xml.Latest.xml | 16 + ...ypedefTest_double_5Fdouble.Xml.Preview.xml | 16 + ...defTest_float_5Ffloat.CSharp.Compatible.cs | 12 + ...ypedefTest_float_5Ffloat.CSharp.Default.cs | 19 + ...TypedefTest_float_5Ffloat.CSharp.Latest.cs | 19 + ...ypedefTest_float_5Ffloat.CSharp.Preview.cs | 19 + ...pedefTest_float_5Ffloat.Xml.Compatible.xml | 10 + ...eTypedefTest_float_5Ffloat.Xml.Default.xml | 16 + ...veTypedefTest_float_5Ffloat.Xml.Latest.xml | 16 + ...eTypedefTest_float_5Ffloat.Xml.Preview.xml | 16 + ...TypedefTest_int_5Fint.CSharp.Compatible.cs | 12 + ...iveTypedefTest_int_5Fint.CSharp.Default.cs | 19 + ...tiveTypedefTest_int_5Fint.CSharp.Latest.cs | 19 + ...iveTypedefTest_int_5Fint.CSharp.Preview.cs | 19 + ...veTypedefTest_int_5Fint.Xml.Compatible.xml | 10 + ...itiveTypedefTest_int_5Fint.Xml.Default.xml | 16 + ...mitiveTypedefTest_int_5Fint.Xml.Latest.xml | 16 + ...itiveTypedefTest_int_5Fint.Xml.Preview.xml | 16 + ...st_long_20long_5Flong.CSharp.Compatible.cs | 12 + ...fTest_long_20long_5Flong.CSharp.Default.cs | 19 + ...efTest_long_20long_5Flong.CSharp.Latest.cs | 19 + ...fTest_long_20long_5Flong.CSharp.Preview.cs | 19 + ...Test_long_20long_5Flong.Xml.Compatible.xml | 10 + ...defTest_long_20long_5Flong.Xml.Default.xml | 16 + ...edefTest_long_20long_5Flong.Xml.Latest.xml | 16 + ...defTest_long_20long_5Flong.Xml.Preview.xml | 16 + ...defTest_short_5Fshort.CSharp.Compatible.cs | 12 + ...ypedefTest_short_5Fshort.CSharp.Default.cs | 19 + ...TypedefTest_short_5Fshort.CSharp.Latest.cs | 19 + ...ypedefTest_short_5Fshort.CSharp.Preview.cs | 19 + ...pedefTest_short_5Fshort.Xml.Compatible.xml | 10 + ...eTypedefTest_short_5Fshort.Xml.Default.xml | 16 + ...veTypedefTest_short_5Fshort.Xml.Latest.xml | 16 + ...eTypedefTest_short_5Fshort.Xml.Preview.xml | 16 + ...signed_20char_5Fsbyte.CSharp.Compatible.cs | 12 + ...st_signed_20char_5Fsbyte.CSharp.Default.cs | 19 + ...est_signed_20char_5Fsbyte.CSharp.Latest.cs | 19 + ...st_signed_20char_5Fsbyte.CSharp.Preview.cs | 19 + ...t_signed_20char_5Fsbyte.Xml.Compatible.xml | 10 + ...Test_signed_20char_5Fsbyte.Xml.Default.xml | 16 + ...fTest_signed_20char_5Fsbyte.Xml.Latest.xml | 16 + ...Test_signed_20char_5Fsbyte.Xml.Preview.xml | 16 + ...nsigned_20char_5Fbyte.CSharp.Compatible.cs | 12 + ...t_unsigned_20char_5Fbyte.CSharp.Default.cs | 19 + ...st_unsigned_20char_5Fbyte.CSharp.Latest.cs | 19 + ...t_unsigned_20char_5Fbyte.CSharp.Preview.cs | 19 + ..._unsigned_20char_5Fbyte.Xml.Compatible.xml | 10 + ...est_unsigned_20char_5Fbyte.Xml.Default.xml | 16 + ...Test_unsigned_20char_5Fbyte.Xml.Latest.xml | 16 + ...est_unsigned_20char_5Fbyte.Xml.Preview.xml | 16 + ...unsigned_20int_5Fuint.CSharp.Compatible.cs | 12 + ...st_unsigned_20int_5Fuint.CSharp.Default.cs | 19 + ...est_unsigned_20int_5Fuint.CSharp.Latest.cs | 19 + ...st_unsigned_20int_5Fuint.CSharp.Preview.cs | 19 + ...t_unsigned_20int_5Fuint.Xml.Compatible.xml | 10 + ...Test_unsigned_20int_5Fuint.Xml.Default.xml | 16 + ...fTest_unsigned_20int_5Fuint.Xml.Latest.xml | 16 + ...Test_unsigned_20int_5Fuint.Xml.Preview.xml | 16 + ...20long_20long_5Fulong.CSharp.Compatible.cs | 12 + ...ed_20long_20long_5Fulong.CSharp.Default.cs | 19 + ...ned_20long_20long_5Fulong.CSharp.Latest.cs | 19 + ...ed_20long_20long_5Fulong.CSharp.Preview.cs | 19 + ...d_20long_20long_5Fulong.Xml.Compatible.xml | 10 + ...gned_20long_20long_5Fulong.Xml.Default.xml | 16 + ...igned_20long_20long_5Fulong.Xml.Latest.xml | 16 + ...gned_20long_20long_5Fulong.Xml.Preview.xml | 16 + ...gned_20short_5Fushort.CSharp.Compatible.cs | 12 + ...nsigned_20short_5Fushort.CSharp.Default.cs | 19 + ...unsigned_20short_5Fushort.CSharp.Latest.cs | 19 + ...nsigned_20short_5Fushort.CSharp.Preview.cs | 19 + ...signed_20short_5Fushort.Xml.Compatible.xml | 10 + ..._unsigned_20short_5Fushort.Xml.Default.xml | 16 + ...t_unsigned_20short_5Fushort.Xml.Latest.xml | 16 + ..._unsigned_20short_5Fushort.Xml.Preview.xml | 16 + .../UnionDeclaration/GuidTest.CSharp.cs | 28 + .../UnionDeclaration/GuidTest.Xml.xml | 19 + ...ble_5Fdouble_5F11_5F5.CSharp.Compatible.cs | 73 + ...double_5Fdouble_5F11_5F5.CSharp.Default.cs | 76 + ..._double_5Fdouble_5F11_5F5.CSharp.Latest.cs | 76 + ...double_5Fdouble_5F11_5F5.CSharp.Preview.cs | 76 + ...ouble_5Fdouble_5F11_5F5.Xml.Compatible.xml | 62 + ...t_double_5Fdouble_5F11_5F5.Xml.Default.xml | 59 + ...st_double_5Fdouble_5F11_5F5.Xml.Latest.xml | 59 + ...t_double_5Fdouble_5F11_5F5.Xml.Preview.xml | 59 + ...loat_5Ffloat_5F11_5F5.CSharp.Compatible.cs | 73 + ...t_float_5Ffloat_5F11_5F5.CSharp.Default.cs | 76 + ...st_float_5Ffloat_5F11_5F5.CSharp.Latest.cs | 76 + ...t_float_5Ffloat_5F11_5F5.CSharp.Preview.cs | 76 + ..._float_5Ffloat_5F11_5F5.Xml.Compatible.xml | 62 + ...est_float_5Ffloat_5F11_5F5.Xml.Default.xml | 59 + ...Test_float_5Ffloat_5F11_5F5.Xml.Latest.xml | 59 + ...est_float_5Ffloat_5F11_5F5.Xml.Preview.xml | 59 + ...st_int_5Fint_5F11_5F5.CSharp.Compatible.cs | 73 + ...sTest_int_5Fint_5F11_5F5.CSharp.Default.cs | 76 + ...usTest_int_5Fint_5F11_5F5.CSharp.Latest.cs | 76 + ...sTest_int_5Fint_5F11_5F5.CSharp.Preview.cs | 76 + ...Test_int_5Fint_5F11_5F5.Xml.Compatible.xml | 62 + ...ousTest_int_5Fint_5F11_5F5.Xml.Default.xml | 59 + ...mousTest_int_5Fint_5F11_5F5.Xml.Latest.xml | 59 + ...ousTest_int_5Fint_5F11_5F5.Xml.Preview.xml | 59 + ...hort_5Fshort_5F11_5F5.CSharp.Compatible.cs | 73 + ...t_short_5Fshort_5F11_5F5.CSharp.Default.cs | 76 + ...st_short_5Fshort_5F11_5F5.CSharp.Latest.cs | 76 + ...t_short_5Fshort_5F11_5F5.CSharp.Preview.cs | 76 + ..._short_5Fshort_5F11_5F5.Xml.Compatible.xml | 62 + ...est_short_5Fshort_5F11_5F5.Xml.Default.xml | 59 + ...Test_short_5Fshort_5F11_5F5.Xml.Latest.xml | 59 + ...est_short_5Fshort_5F11_5F5.Xml.Preview.xml | 59 + ...ymousWithBitfieldTest.CSharp.Compatible.cs | 115 + ...nonymousWithBitfieldTest.CSharp.Default.cs | 112 + ...AnonymousWithBitfieldTest.CSharp.Latest.cs | 112 + ...nonymousWithBitfieldTest.CSharp.Preview.cs | 112 + ...onymousWithBitfieldTest.Xml.Compatible.xml | 88 + ...dAnonymousWithBitfieldTest.Xml.Default.xml | 82 + ...edAnonymousWithBitfieldTest.Xml.Latest.xml | 82 + ...dAnonymousWithBitfieldTest.Xml.Preview.xml | 82 + .../NestedTest_double_5Fdouble.CSharp.cs | 33 + .../NestedTest_double_5Fdouble.Xml.xml | 30 + .../NestedTest_float_5Ffloat.CSharp.cs | 33 + .../NestedTest_float_5Ffloat.Xml.xml | 30 + .../NestedTest_int_5Fint.CSharp.cs | 33 + .../NestedTest_int_5Fint.Xml.xml | 30 + .../NestedTest_short_5Fshort.CSharp.cs | 33 + .../NestedTest_short_5Fshort.Xml.xml | 30 + ...thNativeTypeNameTest_bool_5Fbyte.CSharp.cs | 40 + ...WithNativeTypeNameTest_bool_5Fbyte.Xml.xml | 30 + ...eTypeNameTest_long_20long_5Flong.CSharp.cs | 40 + ...iveTypeNameTest_long_20long_5Flong.Xml.xml | 30 + ...peNameTest_signed_20char_5Fsbyte.CSharp.cs | 40 + ...TypeNameTest_signed_20char_5Fsbyte.Xml.xml | 30 + ...eNameTest_unsigned_20char_5Fbyte.CSharp.cs | 40 + ...ypeNameTest_unsigned_20char_5Fbyte.Xml.xml | 30 + ...peNameTest_unsigned_20int_5Fuint.CSharp.cs | 40 + ...TypeNameTest_unsigned_20int_5Fuint.Xml.xml | 30 + ...t_unsigned_20long_20long_5Fulong.CSharp.cs | 40 + ...est_unsigned_20long_20long_5Fulong.Xml.xml | 30 + ...meTest_unsigned_20short_5Fushort.CSharp.cs | 40 + ...NameTest_unsigned_20short_5Fushort.Xml.xml | 30 + .../UnionDeclaration/NewKeywordTest.CSharp.cs | 29 + .../UnionDeclaration/NewKeywordTest.Xml.xml | 28 + .../NoDefinitionTest.CSharp.cs | 9 + .../UnionDeclaration/NoDefinitionTest.Xml.xml | 6 + .../PointerToSelfTest.CSharp.cs | 14 + .../PointerToSelfTest.Xml.xml | 13 + .../PointerToSelfViaTypedefTest.CSharp.cs | 15 + .../PointerToSelfViaTypedefTest.Xml.xml | 13 + ...apNestedAnonymousTest.CSharp.Compatible.cs | 39 + ...RemapNestedAnonymousTest.CSharp.Default.cs | 38 + .../RemapNestedAnonymousTest.CSharp.Latest.cs | 38 + ...RemapNestedAnonymousTest.CSharp.Preview.cs | 38 + ...emapNestedAnonymousTest.Xml.Compatible.xml | 33 + .../RemapNestedAnonymousTest.Xml.Default.xml | 30 + .../RemapNestedAnonymousTest.Xml.Latest.xml | 30 + .../RemapNestedAnonymousTest.Xml.Preview.xml | 30 + .../UnionDeclaration/RemapTest.CSharp.cs | 9 + .../UnionDeclaration/RemapTest.Xml.xml | 6 + .../SkipNonDefinitionPointerTest.CSharp.cs | 9 + .../SkipNonDefinitionPointerTest.Xml.xml | 6 + ...onDefinitionTest_double_5Fdouble.CSharp.cs | 17 + ...pNonDefinitionTest_double_5Fdouble.Xml.xml | 16 + ...pNonDefinitionTest_float_5Ffloat.CSharp.cs | 17 + ...kipNonDefinitionTest_float_5Ffloat.Xml.xml | 16 + .../SkipNonDefinitionTest_int_5Fint.CSharp.cs | 17 + .../SkipNonDefinitionTest_int_5Fint.Xml.xml | 16 + ...pNonDefinitionTest_short_5Fshort.CSharp.cs | 17 + ...kipNonDefinitionTest_short_5Fshort.Xml.xml | 16 + ...thNativeTypeNameTest_bool_5Fbyte.CSharp.cs | 20 + ...WithNativeTypeNameTest_bool_5Fbyte.Xml.xml | 16 + ...eTypeNameTest_long_20long_5Flong.CSharp.cs | 20 + ...iveTypeNameTest_long_20long_5Flong.Xml.xml | 16 + ...peNameTest_signed_20char_5Fsbyte.CSharp.cs | 20 + ...TypeNameTest_signed_20char_5Fsbyte.Xml.xml | 16 + ...eNameTest_unsigned_20char_5Fbyte.CSharp.cs | 20 + ...ypeNameTest_unsigned_20char_5Fbyte.Xml.xml | 16 + ...peNameTest_unsigned_20int_5Fuint.CSharp.cs | 20 + ...TypeNameTest_unsigned_20int_5Fuint.Xml.xml | 16 + ...t_unsigned_20long_20long_5Fulong.CSharp.cs | 20 + ...est_unsigned_20long_20long_5Fulong.Xml.xml | 16 + ...meTest_unsigned_20short_5Fushort.CSharp.cs | 20 + ...NameTest_unsigned_20short_5Fushort.Xml.xml | 16 + .../TypedefTest_bool_5Fbyte.CSharp.cs | 20 + .../TypedefTest_bool_5Fbyte.Xml.xml | 16 + .../TypedefTest_double_5Fdouble.CSharp.cs | 20 + .../TypedefTest_double_5Fdouble.Xml.xml | 16 + .../TypedefTest_float_5Ffloat.CSharp.cs | 20 + .../TypedefTest_float_5Ffloat.Xml.xml | 16 + .../TypedefTest_int_5Fint.CSharp.cs | 20 + .../TypedefTest_int_5Fint.Xml.xml | 16 + .../TypedefTest_long_20long_5Flong.CSharp.cs | 20 + .../TypedefTest_long_20long_5Flong.Xml.xml | 16 + .../TypedefTest_short_5Fshort.CSharp.cs | 20 + .../TypedefTest_short_5Fshort.Xml.xml | 16 + ...ypedefTest_signed_20char_5Fsbyte.CSharp.cs | 20 + .../TypedefTest_signed_20char_5Fsbyte.Xml.xml | 16 + ...pedefTest_unsigned_20char_5Fbyte.CSharp.cs | 20 + ...TypedefTest_unsigned_20char_5Fbyte.Xml.xml | 16 + ...ypedefTest_unsigned_20int_5Fuint.CSharp.cs | 20 + .../TypedefTest_unsigned_20int_5Fuint.Xml.xml | 16 + ...t_unsigned_20long_20long_5Fulong.CSharp.cs | 20 + ...est_unsigned_20long_20long_5Fulong.Xml.xml | 16 + ...efTest_unsigned_20short_5Fushort.CSharp.cs | 20 + ...edefTest_unsigned_20short_5Fushort.Xml.xml | 16 + ...uctWithAnonUnion.CSharp.Compatible.Unix.cs | 100 + ...WithAnonUnion.CSharp.Compatible.Windows.cs | 82 + ...StructWithAnonUnion.CSharp.Default.Unix.cs | 84 + ...uctWithAnonUnion.CSharp.Default.Windows.cs | 84 + ...nStructWithAnonUnion.CSharp.Latest.Unix.cs | 84 + ...ructWithAnonUnion.CSharp.Latest.Windows.cs | 84 + ...StructWithAnonUnion.CSharp.Preview.Unix.cs | 84 + ...uctWithAnonUnion.CSharp.Preview.Windows.cs | 84 + ...tructWithAnonUnion.Xml.Compatible.Unix.xml | 86 + ...ctWithAnonUnion.Xml.Compatible.Windows.xml | 66 + ...onStructWithAnonUnion.Xml.Default.Unix.xml | 63 + ...tructWithAnonUnion.Xml.Default.Windows.xml | 63 + ...nonStructWithAnonUnion.Xml.Latest.Unix.xml | 63 + ...StructWithAnonUnion.Xml.Latest.Windows.xml | 63 + ...onStructWithAnonUnion.Xml.Preview.Unix.xml | 63 + ...tructWithAnonUnion.Xml.Preview.Windows.xml | 63 + .../VarDeclaration/BasicTest_double.CSharp.cs | 7 + .../VarDeclaration/BasicTest_double.Xml.xml | 13 + .../VarDeclaration/BasicTest_float.CSharp.cs | 7 + .../VarDeclaration/BasicTest_float.Xml.xml | 13 + .../VarDeclaration/BasicTest_int.CSharp.cs | 7 + .../VarDeclaration/BasicTest_int.Xml.xml | 13 + .../VarDeclaration/BasicTest_short.CSharp.cs | 7 + .../VarDeclaration/BasicTest_short.Xml.xml | 13 + ...thNativeTypeNameTest_long_20long.CSharp.cs | 8 + ...WithNativeTypeNameTest_long_20long.Xml.xml | 13 + ...NativeTypeNameTest_signed_20char.CSharp.cs | 8 + ...thNativeTypeNameTest_signed_20char.Xml.xml | 13 + ...tiveTypeNameTest_unsigned_20char.CSharp.cs | 8 + ...NativeTypeNameTest_unsigned_20char.Xml.xml | 13 + ...ativeTypeNameTest_unsigned_20int.CSharp.cs | 8 + ...hNativeTypeNameTest_unsigned_20int.Xml.xml | 13 + ...eNameTest_unsigned_20long_20long.CSharp.cs | 8 + ...ypeNameTest_unsigned_20long_20long.Xml.xml | 13 + ...iveTypeNameTest_unsigned_20short.CSharp.cs | 8 + ...ativeTypeNameTest_unsigned_20short.Xml.xml | 13 + .../ConditionalDefineConstTest.CSharp.cs | 8 + .../ConditionalDefineConstTest.Xml.xml | 15 + .../VarDeclaration/GuidMacroTest.CSharp.cs | 10 + .../VarDeclaration/GuidMacroTest.Xml.xml | 13 + .../VarDeclaration/MacroTest_0.CSharp.cs | 11 + .../VarDeclaration/MacroTest_0.Xml.xml | 19 + .../VarDeclaration/MacroTest_0LL.CSharp.cs | 11 + .../VarDeclaration/MacroTest_0LL.Xml.xml | 19 + .../VarDeclaration/MacroTest_0LLU.CSharp.cs | 11 + .../VarDeclaration/MacroTest_0LLU.Xml.xml | 19 + .../VarDeclaration/MacroTest_0U.CSharp.cs | 11 + .../VarDeclaration/MacroTest_0U.Xml.xml | 19 + .../VarDeclaration/MacroTest_0ULL.CSharp.cs | 11 + .../VarDeclaration/MacroTest_0ULL.Xml.xml | 19 + .../VarDeclaration/MacroTest_0_2E0.CSharp.cs | 11 + .../VarDeclaration/MacroTest_0_2E0.Xml.xml | 19 + .../VarDeclaration/MacroTest_0_2Ef.CSharp.cs | 11 + .../VarDeclaration/MacroTest_0_2Ef.Xml.xml | 19 + .../MultidimensionlArrayTest.CSharp.cs | 20 + .../MultidimensionlArrayTest.Xml.xml | 25 + .../MultilineMacroTest.CSharp.cs | 8 + .../VarDeclaration/MultilineMacroTest.Xml.xml | 13 + .../NoInitializerTest_double.CSharp.cs | 0 .../NoInitializerTest_double.Xml.xml | 0 .../NoInitializerTest_float.CSharp.cs | 0 .../NoInitializerTest_float.Xml.xml | 0 .../NoInitializerTest_int.CSharp.cs | 0 .../NoInitializerTest_int.Xml.xml | 0 .../NoInitializerTest_short.CSharp.cs | 0 .../NoInitializerTest_short.Xml.xml | 0 ...tringLiteralConstTest.CSharp.Compatible.cs | 16 + .../StringLiteralConstTest.CSharp.Default.cs | 16 + .../StringLiteralConstTest.CSharp.Latest.cs | 16 + .../StringLiteralConstTest.CSharp.Preview.cs | 16 + .../StringLiteralConstTest.Xml.Compatible.xml | 25 + .../StringLiteralConstTest.Xml.Default.xml | 25 + .../StringLiteralConstTest.Xml.Latest.xml | 25 + .../StringLiteralConstTest.Xml.Preview.xml | 25 + ...iteralStaticConstTest.CSharp.Compatible.cs | 16 + ...ngLiteralStaticConstTest.CSharp.Default.cs | 16 + ...ingLiteralStaticConstTest.CSharp.Latest.cs | 16 + ...ngLiteralStaticConstTest.CSharp.Preview.cs | 16 + ...gLiteralStaticConstTest.Xml.Compatible.xml | 25 + ...ringLiteralStaticConstTest.Xml.Default.xml | 25 + ...tringLiteralStaticConstTest.Xml.Latest.xml | 25 + ...ringLiteralStaticConstTest.Xml.Preview.xml | 25 + ...versionMacroTest.CSharp.Compatible.Unix.cs | 13 + ...sionMacroTest.CSharp.Compatible.Windows.cs | 11 + ...ConversionMacroTest.CSharp.Default.Unix.cs | 11 + ...versionMacroTest.CSharp.Default.Windows.cs | 11 + ...dConversionMacroTest.CSharp.Latest.Unix.cs | 11 + ...nversionMacroTest.CSharp.Latest.Windows.cs | 11 + ...ConversionMacroTest.CSharp.Preview.Unix.cs | 11 + ...versionMacroTest.CSharp.Preview.Windows.cs | 11 + ...onversionMacroTest.Xml.Compatible.Unix.xml | 27 + ...ersionMacroTest.Xml.Compatible.Windows.xml | 27 + ...edConversionMacroTest.Xml.Default.Unix.xml | 27 + ...onversionMacroTest.Xml.Default.Windows.xml | 27 + ...kedConversionMacroTest.Xml.Latest.Unix.xml | 27 + ...ConversionMacroTest.Xml.Latest.Windows.xml | 27 + ...edConversionMacroTest.Xml.Preview.Unix.xml | 27 + ...onversionMacroTest.Xml.Preview.Windows.xml | 27 + ...ersionMacroTest2.CSharp.Compatible.Unix.cs | 10 + ...ionMacroTest2.CSharp.Compatible.Windows.cs | 8 + ...onversionMacroTest2.CSharp.Default.Unix.cs | 8 + ...ersionMacroTest2.CSharp.Default.Windows.cs | 8 + ...ConversionMacroTest2.CSharp.Latest.Unix.cs | 8 + ...versionMacroTest2.CSharp.Latest.Windows.cs | 8 + ...onversionMacroTest2.CSharp.Preview.Unix.cs | 8 + ...ersionMacroTest2.CSharp.Preview.Windows.cs | 8 + ...nversionMacroTest2.Xml.Compatible.Unix.xml | 15 + ...rsionMacroTest2.Xml.Compatible.Windows.xml | 15 + ...dConversionMacroTest2.Xml.Default.Unix.xml | 15 + ...nversionMacroTest2.Xml.Default.Windows.xml | 15 + ...edConversionMacroTest2.Xml.Latest.Unix.xml | 15 + ...onversionMacroTest2.Xml.Latest.Windows.xml | 15 + ...dConversionMacroTest2.Xml.Preview.Unix.xml | 15 + ...nversionMacroTest2.Xml.Preview.Windows.xml | 15 + ...checkedFunctionLikeCastMacroTest.CSharp.cs | 8 + ...UncheckedFunctionLikeCastMacroTest.Xml.xml | 17 + .../UncheckedPointerMacroTest.CSharp.cs | 8 + .../UncheckedPointerMacroTest.Xml.xml | 15 + ...ncheckedReinterpretCastMacroTest.CSharp.cs | 8 + .../UncheckedReinterpretCastMacroTest.Xml.xml | 17 + .../UndefinedFunctionLikeMacroTest.CSharp.cs | 0 .../UndefinedFunctionLikeMacroTest.Xml.xml | 0 .../Utf16StringLiteralMacroTest.CSharp.cs | 8 + .../Utf16StringLiteralMacroTest.Xml.xml | 13 + ...tringLiteralMacroTest.CSharp.Compatible.cs | 10 + ...f8StringLiteralMacroTest.CSharp.Default.cs | 10 + ...tf8StringLiteralMacroTest.CSharp.Latest.cs | 10 + ...f8StringLiteralMacroTest.CSharp.Preview.cs | 10 + ...8StringLiteralMacroTest.Xml.Compatible.xml | 13 + ...Utf8StringLiteralMacroTest.Xml.Default.xml | 13 + .../Utf8StringLiteralMacroTest.Xml.Latest.xml | 13 + ...Utf8StringLiteralMacroTest.Xml.Preview.xml | 13 + ...LiteralConstTest.CSharp.Compatible.Unix.cs | 14 + ...eralConstTest.CSharp.Compatible.Windows.cs | 14 + ...ingLiteralConstTest.CSharp.Default.Unix.cs | 16 + ...LiteralConstTest.CSharp.Default.Windows.cs | 14 + ...ringLiteralConstTest.CSharp.Latest.Unix.cs | 16 + ...gLiteralConstTest.CSharp.Latest.Windows.cs | 14 + ...ingLiteralConstTest.CSharp.Preview.Unix.cs | 16 + ...LiteralConstTest.CSharp.Preview.Windows.cs | 14 + ...ngLiteralConstTest.Xml.Compatible.Unix.xml | 25 + ...iteralConstTest.Xml.Compatible.Windows.xml | 25 + ...tringLiteralConstTest.Xml.Default.Unix.xml | 25 + ...ngLiteralConstTest.Xml.Default.Windows.xml | 25 + ...StringLiteralConstTest.Xml.Latest.Unix.xml | 25 + ...ingLiteralConstTest.Xml.Latest.Windows.xml | 25 + ...tringLiteralConstTest.Xml.Preview.Unix.xml | 25 + ...ngLiteralConstTest.Xml.Preview.Windows.xml | 25 + ...lStaticConstTest.CSharp.Compatible.Unix.cs | 14 + ...aticConstTest.CSharp.Compatible.Windows.cs | 14 + ...eralStaticConstTest.CSharp.Default.Unix.cs | 16 + ...lStaticConstTest.CSharp.Default.Windows.cs | 14 + ...teralStaticConstTest.CSharp.Latest.Unix.cs | 16 + ...alStaticConstTest.CSharp.Latest.Windows.cs | 14 + ...eralStaticConstTest.CSharp.Preview.Unix.cs | 16 + ...lStaticConstTest.CSharp.Preview.Windows.cs | 14 + ...ralStaticConstTest.Xml.Compatible.Unix.xml | 25 + ...StaticConstTest.Xml.Compatible.Windows.xml | 25 + ...iteralStaticConstTest.Xml.Default.Unix.xml | 25 + ...ralStaticConstTest.Xml.Default.Windows.xml | 25 + ...LiteralStaticConstTest.Xml.Latest.Unix.xml | 25 + ...eralStaticConstTest.Xml.Latest.Windows.xml | 25 + ...iteralStaticConstTest.Xml.Preview.Unix.xml | 25 + ...ralStaticConstTest.Xml.Preview.Windows.xml | 25 + .../Baseline/CXXMethodDeclarationTest.cs | 360 +++ .../Baseline/DeprecatedToObsoleteTest.cs | 253 ++ .../Baseline/DigitsSeparatorTest.cs | 37 + .../Baseline/EnumDeclarationTest.cs | 345 +++ .../FunctionDeclarationBodyImportTest.cs | 913 +++++++ .../FunctionDeclarationDllImportTest.cs | 220 ++ .../FunctionPointerDeclarationTest.cs | 46 + .../Baseline/StructDeclarationTest.cs | 831 +++++++ .../Baseline/UnionDeclarationTest.cs | 593 +++++ .../Baseline/VarDeclarationTest.cs | 157 ++ .../CXXMethodDeclarationTest.cs | 532 ---- .../DeprecatedToObsoleteTest.cs | 521 ---- .../DigitsSeparatorTest.cs | 35 - .../EnumDeclarationTest.cs | 610 ----- .../FunctionDeclarationBodyImportTest.cs | 1795 -------------- .../FunctionDeclarationDllImportTest.cs | 412 ---- .../FunctionPointerDeclarationTest.cs | 94 - .../StructDeclarationTest.cs | 2153 ---------------- .../UnionDeclarationTest.cs | 1584 ------------ .../VarDeclarationTest.cs | 411 ---- .../CXXMethodDeclarationTest.cs | 527 ---- .../DeprecatedToObsoleteTest.cs | 521 ---- .../DigitsSeparatorTest.cs | 35 - .../EnumDeclarationTest.cs | 611 ----- .../FunctionDeclarationBodyImportTest.cs | 1795 -------------- .../FunctionDeclarationDllImportTest.cs | 429 ---- .../FunctionPointerDeclarationTest.cs | 94 - .../StructDeclarationTest.cs | 2159 ----------------- .../UnionDeclarationTest.cs | 1573 ------------ .../VarDeclarationTest.cs | 408 ---- .../CXXMethodDeclarationTest.cs | 419 ---- .../DeprecatedToObsoleteTest.cs | 506 ---- .../CSharpDefaultUnix/DigitsSeparatorTest.cs | 35 - .../CSharpDefaultUnix/EnumDeclarationTest.cs | 611 ----- .../FunctionDeclarationBodyImportTest.cs | 1781 -------------- .../FunctionDeclarationDllImportTest.cs | 411 ---- .../FunctionPointerDeclarationTest.cs | 76 - .../StructDeclarationTest.cs | 2082 ---------------- .../CSharpDefaultUnix/UnionDeclarationTest.cs | 1513 ------------ .../CSharpDefaultUnix/VarDeclarationTest.cs | 410 ---- .../CXXMethodDeclarationTest.cs | 424 ---- .../DeprecatedToObsoleteTest.cs | 506 ---- .../DigitsSeparatorTest.cs | 35 - .../EnumDeclarationTest.cs | 610 ----- .../FunctionDeclarationBodyImportTest.cs | 1781 -------------- .../FunctionDeclarationDllImportTest.cs | 428 ---- .../FunctionPointerDeclarationTest.cs | 76 - .../StructDeclarationTest.cs | 2088 ---------------- .../UnionDeclarationTest.cs | 1519 ------------ .../VarDeclarationTest.cs | 408 ---- .../CXXMethodDeclarationTest.cs | 419 ---- .../DeprecatedToObsoleteTest.cs | 506 ---- .../CSharpLatestUnix/DigitsSeparatorTest.cs | 35 - .../CSharpLatestUnix/EnumDeclarationTest.cs | 611 ----- .../FunctionDeclarationBodyImportTest.cs | 1781 -------------- .../FunctionDeclarationDllImportTest.cs | 411 ---- .../FunctionPointerDeclarationTest.cs | 76 - .../CSharpLatestUnix/StructDeclarationTest.cs | 2082 ---------------- .../CSharpLatestUnix/UnionDeclarationTest.cs | 1513 ------------ .../CSharpLatestUnix/VarDeclarationTest.cs | 410 ---- .../CXXMethodDeclarationTest.cs | 419 ---- .../DeprecatedToObsoleteTest.cs | 506 ---- .../DigitsSeparatorTest.cs | 35 - .../EnumDeclarationTest.cs | 611 ----- .../FunctionDeclarationBodyImportTest.cs | 1781 -------------- .../FunctionDeclarationDllImportTest.cs | 428 ---- .../FunctionPointerDeclarationTest.cs | 76 - .../StructDeclarationTest.cs | 2088 ---------------- .../UnionDeclarationTest.cs | 1519 ------------ .../CSharpLatestWindows/VarDeclarationTest.cs | 408 ---- .../CXXMethodDeclarationTest.cs | 419 ---- .../DeprecatedToObsoleteTest.cs | 506 ---- .../CSharpPreviewUnix/DigitsSeparatorTest.cs | 35 - .../CSharpPreviewUnix/EnumDeclarationTest.cs | 611 ----- .../FunctionDeclarationBodyImportTest.cs | 1781 -------------- .../FunctionDeclarationDllImportTest.cs | 411 ---- .../FunctionPointerDeclarationTest.cs | 76 - .../StructDeclarationTest.cs | 2081 ---------------- .../CSharpPreviewUnix/UnionDeclarationTest.cs | 1513 ------------ .../CSharpPreviewUnix/VarDeclarationTest.cs | 412 ---- .../CXXMethodDeclarationTest.cs | 419 ---- .../DeprecatedToObsoleteTest.cs | 506 ---- .../DigitsSeparatorTest.cs | 35 - .../EnumDeclarationTest.cs | 611 ----- .../FunctionDeclarationBodyImportTest.cs | 1781 -------------- .../FunctionDeclarationDllImportTest.cs | 428 ---- .../FunctionPointerDeclarationTest.cs | 76 - .../StructDeclarationTest.cs | 2087 ---------------- .../UnionDeclarationTest.cs | 1519 ------------ .../VarDeclarationTest.cs | 408 ---- .../CXXMethodDeclarationTest.cs | 656 ----- .../DeprecatedToObsoleteTest.cs | 551 ----- .../XmlCompatibleUnix/DigitsSeparatorTest.cs | 40 - .../XmlCompatibleUnix/EnumDeclarationTest.cs | 730 ------ .../FunctionDeclarationBodyImportTest.cs | 2013 --------------- .../FunctionDeclarationDllImportTest.cs | 464 ---- .../FunctionPointerDeclarationTest.cs | 91 - .../StructDeclarationTest.cs | 2117 ---------------- .../XmlCompatibleUnix/UnionDeclarationTest.cs | 1459 ----------- .../XmlCompatibleUnix/VarDeclarationTest.cs | 543 ----- .../CXXMethodDeclarationTest.cs | 657 ----- .../DeprecatedToObsoleteTest.cs | 551 ----- .../DigitsSeparatorTest.cs | 40 - .../EnumDeclarationTest.cs | 730 ------ .../FunctionDeclarationBodyImportTest.cs | 2013 --------------- .../FunctionDeclarationDllImportTest.cs | 464 ---- .../FunctionPointerDeclarationTest.cs | 91 - .../StructDeclarationTest.cs | 2126 ---------------- .../UnionDeclarationTest.cs | 1445 ----------- .../VarDeclarationTest.cs | 543 ----- .../CXXMethodDeclarationTest.cs | 477 ---- .../DeprecatedToObsoleteTest.cs | 537 ---- .../XmlDefaultUnix/DigitsSeparatorTest.cs | 40 - .../XmlDefaultUnix/EnumDeclarationTest.cs | 730 ------ .../FunctionDeclarationBodyImportTest.cs | 1992 --------------- .../FunctionDeclarationDllImportTest.cs | 464 ---- .../FunctionPointerDeclarationTest.cs | 82 - .../XmlDefaultUnix/StructDeclarationTest.cs | 1951 --------------- .../XmlDefaultUnix/UnionDeclarationTest.cs | 1311 ---------- .../XmlDefaultUnix/VarDeclarationTest.cs | 543 ----- .../CXXMethodDeclarationTest.cs | 477 ---- .../DeprecatedToObsoleteTest.cs | 537 ---- .../XmlDefaultWindows/DigitsSeparatorTest.cs | 39 - .../XmlDefaultWindows/EnumDeclarationTest.cs | 730 ------ .../FunctionDeclarationBodyImportTest.cs | 1992 --------------- .../FunctionDeclarationDllImportTest.cs | 464 ---- .../FunctionPointerDeclarationTest.cs | 82 - .../StructDeclarationTest.cs | 1961 --------------- .../XmlDefaultWindows/UnionDeclarationTest.cs | 1317 ---------- .../XmlDefaultWindows/VarDeclarationTest.cs | 543 ----- .../XmlLatestUnix/CXXMethodDeclarationTest.cs | 477 ---- .../XmlLatestUnix/DeprecatedToObsoleteTest.cs | 537 ---- .../XmlLatestUnix/DigitsSeparatorTest.cs | 39 - .../XmlLatestUnix/EnumDeclarationTest.cs | 730 ------ .../FunctionDeclarationBodyImportTest.cs | 1992 --------------- .../FunctionDeclarationDllImportTest.cs | 464 ---- .../FunctionPointerDeclarationTest.cs | 82 - .../XmlLatestUnix/StructDeclarationTest.cs | 1951 --------------- .../XmlLatestUnix/UnionDeclarationTest.cs | 1311 ---------- .../XmlLatestUnix/VarDeclarationTest.cs | 543 ----- .../CXXMethodDeclarationTest.cs | 477 ---- .../DeprecatedToObsoleteTest.cs | 537 ---- .../XmlLatestWindows/DigitsSeparatorTest.cs | 40 - .../XmlLatestWindows/EnumDeclarationTest.cs | 730 ------ .../FunctionDeclarationBodyImportTest.cs | 1992 --------------- .../FunctionDeclarationDllImportTest.cs | 464 ---- .../FunctionPointerDeclarationTest.cs | 82 - .../XmlLatestWindows/StructDeclarationTest.cs | 1961 --------------- .../XmlLatestWindows/UnionDeclarationTest.cs | 1317 ---------- .../XmlLatestWindows/VarDeclarationTest.cs | 544 ----- .../CXXMethodDeclarationTest.cs | 475 ---- .../DeprecatedToObsoleteTest.cs | 537 ---- .../XmlPreviewUnix/DigitsSeparatorTest.cs | 40 - .../XmlPreviewUnix/EnumDeclarationTest.cs | 730 ------ .../FunctionDeclarationBodyImportTest.cs | 1992 --------------- .../FunctionDeclarationDllImportTest.cs | 464 ---- .../FunctionPointerDeclarationTest.cs | 82 - .../XmlPreviewUnix/StructDeclarationTest.cs | 1949 --------------- .../XmlPreviewUnix/UnionDeclarationTest.cs | 1311 ---------- .../XmlPreviewUnix/VarDeclarationTest.cs | 543 ----- .../CXXMethodDeclarationTest.cs | 476 ---- .../DeprecatedToObsoleteTest.cs | 537 ---- .../XmlPreviewWindows/DigitsSeparatorTest.cs | 40 - .../XmlPreviewWindows/EnumDeclarationTest.cs | 730 ------ .../FunctionDeclarationBodyImportTest.cs | 1992 --------------- .../FunctionDeclarationDllImportTest.cs | 464 ---- .../FunctionPointerDeclarationTest.cs | 82 - .../StructDeclarationTest.cs | 1959 --------------- .../XmlPreviewWindows/UnionDeclarationTest.cs | 1317 ---------- .../XmlPreviewWindows/VarDeclarationTest.cs | 543 ----- 2111 files changed, 57553 insertions(+), 132289 deletions(-) delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationCSharpTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationXmlTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Base/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Base/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Base/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorWithInitializeTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorWithInitializeTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConversionTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConversionTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Compatible.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Default.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Latest.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Preview.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DestructorTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DestructorTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MacrosExpansionTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MacrosExpansionTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberCallTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberCallTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Compatible.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Default.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Latest.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Preview.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Compatible.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Default.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Latest.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Preview.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Compatible.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Default.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Latest.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Preview.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorCallTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorCallTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ThisTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ThisTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/UnsafeDoesNotImpactDllImportTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/UnsafeDoesNotImpactDllImportTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/EnumDecl.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/EnumDecl.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDecl.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDecl.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDeclDllImport.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDeclDllImport.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/InstanceFunc.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/InstanceFunc.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleEnumMembers.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleEnumMembers.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleStructMembers_int_5Fint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleStructMembers_int_5Fint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleTypedefStructMembers_int_5Fint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleTypedefStructMembers_int_5Fint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleVarDecl_int_5Fint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleVarDecl_int_5Fint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/StructDecl.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/StructDecl.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/TypedefStructDecl.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/TypedefStructDecl.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_2E0_5F1_5F024_2E0.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_2E0_5F1_5F024_2E0.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_5F1_5F024.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_5F1_5F024.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27000_27001_5F1_5F000_5F001.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27000_27001_5F1_5F000_5F001.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27024_5F1_5F024.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27024_5F1_5F024.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicValueTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicValueTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExcludeTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExcludeTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedTest_short_5Fshort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedTest_short_5Fshort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_long_20long_5Flong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/RemapTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/RemapTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Compatible.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Default.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Latest.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Preview.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAttributeTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAttributeTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithCastToEnumType.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithCastToEnumType.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithImplicitConversionTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithImplicitConversionTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithMultipleEnumsTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithMultipleEnumsTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarPlusTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarPlusTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Compatible.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Default.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Latest.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Preview.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeAndImplicitConversionTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeAndImplicitConversionTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarOverrideTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarOverrideTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ArraySubscriptTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ArraySubscriptTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BasicTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BasicTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25_3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25_3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26_3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26_3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A_3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A_3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B_3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B_3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D_3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D_3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F_3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F_3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C_3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C_3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E_3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E_3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E_3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E_3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C_3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C_3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__26_26.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__26_26.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__7C_7C.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__7C_7C.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__21_3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__21_3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C_3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C_3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3D_3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3D_3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E_3D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E_3D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BreakTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BreakTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CStyleFunctionalCastTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CStyleFunctionalCastTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionWithArgsTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionWithArgsTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseNoCompoundTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseNoCompoundTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CompareMultipleEnumTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CompareMultipleEnumTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ConditionalOperatorTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ConditionalOperatorTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ContinueTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ContinueTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxConstCastTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxConstCastTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxFunctionalCastTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxFunctionalCastTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxReinterpretCastTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxReinterpretCastTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxStaticCastTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxStaticCastTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DeclTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DeclTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoNonCompoundTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoNonCompoundTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForNonCompoundTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForNonCompoundTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseIfTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseIfTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseNonCompoundTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseNonCompoundTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForArrayTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForArrayTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForRecordDeclTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForRecordDeclTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/MemberTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/MemberTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/RefToPtrTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/RefToPtrTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_false.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_false.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_true.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_true.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXNullPtrTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXNullPtrTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnEmptyTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnEmptyTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_3_2E14.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_3_2E14.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_5e_2D1.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_5e_2D1.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_3_2E14f.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_3_2E14f.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_5e_2D1f.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_5e_2D1f.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnIntegerLiteralInt32Test.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnIntegerLiteralInt32Test.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnStructTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnStructTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchNonCompoundTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchNonCompoundTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorAddrOfTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorAddrOfTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorDerefTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorDerefTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorLogicalNotTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorLogicalNotTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2B_2B.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2B_2B.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2D_2D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2D_2D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B_2B.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B_2B.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D_2D.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D_2D.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__7E.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__7E.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileNonCompoundTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileNonCompoundTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/ArrayParameterTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/ArrayParameterTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/BasicTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/BasicTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/IntrinsicsTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/IntrinsicsTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NoLibraryPathTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NoLibraryPathTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_double_5F1_2E0_5FFalse_5Fdouble_5F1_2E0.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_double_5F1_2E0_5FFalse_5Fdouble_5F1_2E0.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_float_5F6_2E0f_5FFalse_5Ffloat_5F6_2E0f.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_float_5F6_2E0f_5FFalse_5Ffloat_5F6_2E0f.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_int_5F3_5FFalse_5Fint_5F3.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_int_5F3_5FFalse_5Fint_5F3.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_long_20long_5F4_5FTrue_5Flong_5F4.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_long_20long_5F4_5FTrue_5Flong_5F4.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_short_5F2_5FFalse_5Fshort_5F2.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_short_5F2_5FFalse_5Fshort_5F2.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_signed_20char_5F5_5FTrue_5Fsbyte_5F5.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_signed_20char_5F5_5FTrue_5Fsbyte_5F5.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20char_5F0_5FTrue_5Fbyte_5F0.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20char_5F0_5FTrue_5Fbyte_5F0.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20int_5F8_5FTrue_5Fuint_5F8.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20int_5F8_5FTrue_5Fuint_5F8.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20long_20long_5F9_5FTrue_5Fulong_5F9.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20long_20long_5F9_5FTrue_5Fulong_5F9.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F7_5FTrue_5Fushort_5F7.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F7_5FTrue_5Fushort_5F7.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F_27A_27_5FTrue_5Fushort_5F_28byte_29_28_27A_27_29.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F_27A_27_5FTrue_5Fushort_5F_28byte_29_28_27A_27_29.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5F0_5Fvoid_2A_5Fnull.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5F0_5Fvoid_2A_5Fnull.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5Fnullptr_5Fvoid_2A_5Fnull.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5Fnullptr_5Fvoid_2A_5Fnull.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/SourceLocationTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/SourceLocationTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateMemberTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateMemberTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_bool_5FTrue_5Fbyte_5F.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_bool_5FTrue_5Fbyte_5F.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_float_20_2A_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_float_20_2A_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_int_5FFalse_5Fint_5F.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_int_5FFalse_5Fint_5F.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_void_20_28_2A_29_28int_29_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_void_20_28_2A_29_28int_29_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarOverrideTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarOverrideTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathStarTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathStarTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorStarTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorStarTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_double_5Fdouble.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_double_5Fdouble.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_float_5Ffloat.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_float_5Ffloat.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_int_5Fint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_int_5Fint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_short_5Fshort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_short_5Fshort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_double_5Fdouble.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_double_5Fdouble.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_float_5Ffloat.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_float_5Ffloat.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_int_5Fint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_int_5Fint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_short_5Fshort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_short_5Fshort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Compatible.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Default.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Latest.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Preview.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Compatible.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Default.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Latest.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Preview.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/ExcludeTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/ExcludeTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/GuidTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/GuidTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceWithNativeInheritanceAttributeTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceWithNativeInheritanceAttributeTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_double_5Fdouble.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_double_5Fdouble.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_float_5Ffloat.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_float_5Ffloat.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_int_5Fint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_int_5Fint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_short_5Fshort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_short_5Fshort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NewKeywordTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NewKeywordTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NoDefinitionTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NoDefinitionTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PackTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PackTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfViaTypedefTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfViaTypedefTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionPointerTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionPointerTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_double_5Fdouble.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_double_5Fdouble.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_float_5Ffloat.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_float_5Ffloat.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_int_5Fint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_int_5Fint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_short_5Fshort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_short_5Fshort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SourceLocationAttributeTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SourceLocationAttributeTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_bool_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_bool_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_double_5Fdouble.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_double_5Fdouble.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_float_5Ffloat.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_float_5Ffloat.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_int_5Fint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_int_5Fint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_long_20long_5Flong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_long_20long_5Flong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_short_5Fshort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_short_5Fshort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_signed_20char_5Fsbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_signed_20char_5Fsbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20char_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20char_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20int_5Fuint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20int_5Fuint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20short_5Fushort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20short_5Fushort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/UsingDeclarationTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/UsingDeclarationTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithAccessSpecifierTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithAccessSpecifierTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_double_5Fdouble.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_double_5Fdouble.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_float_5Ffloat.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_float_5Ffloat.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_int_5Fint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_int_5Fint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_short_5Fshort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_short_5Fshort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_double_5Fdouble.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_double_5Fdouble.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_float_5Ffloat.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_float_5Ffloat.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_int_5Fint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_int_5Fint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_short_5Fshort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_short_5Fshort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Compatible.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Default.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Latest.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Preview.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/ExcludeTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/ExcludeTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/GuidTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/GuidTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_double_5Fdouble.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_double_5Fdouble.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_float_5Ffloat.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_float_5Ffloat.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_int_5Fint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_int_5Fint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_short_5Fshort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_short_5Fshort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NewKeywordTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NewKeywordTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NoDefinitionTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NoDefinitionTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfViaTypedefTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfViaTypedefTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionPointerTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionPointerTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_double_5Fdouble.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_double_5Fdouble.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_float_5Ffloat.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_float_5Ffloat.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_int_5Fint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_int_5Fint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_short_5Fshort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_short_5Fshort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_bool_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_bool_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_double_5Fdouble.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_double_5Fdouble.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_float_5Ffloat.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_float_5Ffloat.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_int_5Fint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_int_5Fint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_long_20long_5Flong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_long_20long_5Flong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_short_5Fshort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_short_5Fshort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_signed_20char_5Fsbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_signed_20char_5Fsbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20char_5Fbyte.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20char_5Fbyte.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20int_5Fuint.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20int_5Fuint.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20short_5Fushort.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20short_5Fushort.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Compatible.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Default.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Latest.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Preview.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_double.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_double.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_float.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_float.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_int.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_int.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_short.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_short.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_long_20long.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_long_20long.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_signed_20char.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_signed_20char.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20char.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20char.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20int.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20int.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20short.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20short.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/ConditionalDefineConstTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/ConditionalDefineConstTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/GuidMacroTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/GuidMacroTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LL.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LL.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LLU.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LLU.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0U.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0U.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0ULL.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0ULL.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2E0.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2E0.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2Ef.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2Ef.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultidimensionlArrayTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultidimensionlArrayTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultilineMacroTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultilineMacroTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_double.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_double.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_float.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_float.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_int.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_int.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_short.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_short.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Compatible.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Default.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Latest.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Preview.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Compatible.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Default.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Latest.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Preview.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedFunctionLikeCastMacroTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedFunctionLikeCastMacroTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedPointerMacroTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedPointerMacroTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedReinterpretCastMacroTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedReinterpretCastMacroTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UndefinedFunctionLikeMacroTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UndefinedFunctionLikeMacroTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf16StringLiteralMacroTest.CSharp.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf16StringLiteralMacroTest.Xml.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Compatible.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Default.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Latest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Preview.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Compatible.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Default.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Latest.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Preview.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Compatible.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Default.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Latest.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Preview.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Default.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Default.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Preview.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Preview.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Compatible.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Compatible.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Default.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Default.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Latest.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Latest.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Preview.Unix.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Preview.Windows.xml create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/CXXMethodDeclarationTest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/DeprecatedToObsoleteTest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/DigitsSeparatorTest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/EnumDeclarationTest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/FunctionDeclarationBodyImportTest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/FunctionDeclarationDllImportTest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/FunctionPointerDeclarationTest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/StructDeclarationTest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/UnionDeclarationTest.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/CXXMethodDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/DeprecatedToObsoleteTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/DigitsSeparatorTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationBodyImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionPointerDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs delete mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationCSharpTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationCSharpTest.cs deleted file mode 100644 index 13730c79..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationCSharpTest.cs +++ /dev/null @@ -1,614 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; - -namespace ClangSharp.UnitTests; - -public abstract class CXXMethodDeclarationCSharpTest : CXXMethodDeclarationTest -{ - protected override Task ConstructorTestImpl() - { - var inputContents = @"struct MyStruct -{ - int _value; - - MyStruct(int value) - { - _value = value; - } -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int _value; - - public MyStruct(int value) - { - _value = value; - } - } -} -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConstructorWithInitializeTestImpl() - { - var inputContents = @"struct MyStruct -{ - int _x; - int _y; - int _z; - - MyStruct(int x) : _x(x) - { - } - - MyStruct(int x, int y) : _x(x), _y(y) - { - } - - MyStruct(int x, int y, int z) : _x(x), _y(y), _z() - { - } -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int _x; - - public int _y; - - public int _z; - - public MyStruct(int x) - { - _x = x; - } - - public MyStruct(int x, int y) - { - _x = x; - _y = y; - } - - public MyStruct(int x, int y, int z) - { - _x = x; - _y = y; - } - } -} -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConversionTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; - int* pointer; - int** pointer2; - int*** pointer3; - operator int() - { - return value; - } - operator int*() - { - return pointer; - } - operator int**() - { - return pointer2; - } - operator int***() - { - return pointer3; - } -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - public int value; - - public int* pointer; - - public int** pointer2; - - public int*** pointer3; - - public int ToInt32() - { - return value; - } - - public int* ToInt32Pointer() - { - return pointer; - } - - public int** ToInt32PointerPointer() - { - return pointer2; - } - - public int*** ToInt32PointerPointerPointer() - { - return pointer3; - } - } -} -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DestructorTestImpl() - { - var inputContents = @"struct MyStruct -{ - ~MyStruct() - { - } -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public void Dispose() - { - } - } -} -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MacrosExpansionTestImpl() - { - var inputContents = @"typedef struct -{ - unsigned char *buf; - int size; -} context_t; - -int buf_close(void *pContext) -{ - ((context_t*)pContext)->buf=0; - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct context_t - { - [NativeTypeName(""unsigned char *"")] - public byte* buf; - - public int size; - } - - public static unsafe partial class Methods - { - public static int buf_close(void* pContext) - { - ((context_t*)(pContext))->buf = null; - return 0; - } - } -} -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberCallTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; - - int MyFunction1() - { - return value; - } - - int MyFunction2() - { - return MyFunction1(); - } - - int MyFunction3() - { - return this->MyFunction1(); - } -}; - -int MyFunctionA(MyStruct x) -{ - return x.MyFunction1(); -} - -int MyFunctionB(MyStruct* x) -{ - return x->MyFunction2(); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - - public int MyFunction1() - { - return value; - } - - public int MyFunction2() - { - return MyFunction1(); - } - - public int MyFunction3() - { - return this.MyFunction1(); - } - } - - public static unsafe partial class Methods - { - public static int MyFunctionA(MyStruct x) - { - return x.MyFunction1(); - } - - public static int MyFunctionB(MyStruct* x) - { - return x->MyFunction2(); - } - } -} -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; - - int MyFunction() - { - return value; - } -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - - public int MyFunction() - { - return value; - } - } -} -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals() { return 0; } - int Equals(int obj) { return 0; } - int Dispose() { return 0; } - int Dispose(int obj) { return 0; } - int GetHashCode() { return 0; } - int GetHashCode(int obj) { return 0; } - int GetType() { return 0; } - int GetType(int obj) { return 0; } - int MemberwiseClone() { return 0; } - int MemberwiseClone(int obj) { return 0; } - int ReferenceEquals() { return 0; } - int ReferenceEquals(int obj) { return 0; } - int ToString() { return 0; } - int ToString(int obj) { return 0; } -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public int Equals() - {{ - return 0; - }} - - public int Equals(int obj) - {{ - return 0; - }} - - public int Dispose() - {{ - return 0; - }} - - public int Dispose(int obj) - {{ - return 0; - }} - - public new int GetHashCode() - {{ - return 0; - }} - - public int GetHashCode(int obj) - {{ - return 0; - }} - - public new int GetType() - {{ - return 0; - }} - - public int GetType(int obj) - {{ - return 0; - }} - - public new int MemberwiseClone() - {{ - return 0; - }} - - public int MemberwiseClone(int obj) - {{ - return 0; - }} - - public int ReferenceEquals() - {{ - return 0; - }} - - public int ReferenceEquals(int obj) - {{ - return 0; - }} - - public new int ToString() - {{ - return 0; - }} - - public int ToString(int obj) - {{ - return 0; - }} - }} -}} -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OperatorTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; - - MyStruct(int value) : value(value) - { - } - - MyStruct operator+(MyStruct rhs) - { - return MyStruct(value + rhs.value); - } -}; - -MyStruct operator-(MyStruct lhs, MyStruct rhs) -{ - return MyStruct(lhs.value - rhs.value); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - - public MyStruct(int value) - { - this.value = value; - } - - public MyStruct Add(MyStruct rhs) - { - return new MyStruct(value + rhs.value); - } - } - - public static partial class Methods - { - public static MyStruct Subtract(MyStruct lhs, MyStruct rhs) - { - return new MyStruct(lhs.value - rhs.value); - } - } -} -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OperatorCallTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; - - MyStruct(int value) : value(value) - { - } - - MyStruct operator+(MyStruct rhs) - { - return MyStruct(value + rhs.value); - } -}; - -MyStruct MyFunction1(MyStruct lhs, MyStruct rhs) -{ - return lhs + rhs; -} - -MyStruct operator-(MyStruct lhs, MyStruct rhs) -{ - return MyStruct(lhs.value - rhs.value); -} - -MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) -{ - return lhs - rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - - public MyStruct(int value) - { - this.value = value; - } - - public MyStruct Add(MyStruct rhs) - { - return new MyStruct(value + rhs.value); - } - } - - public static partial class Methods - { - public static MyStruct MyFunction1(MyStruct lhs, MyStruct rhs) - { - return lhs.Add(rhs); - } - - public static MyStruct Subtract(MyStruct lhs, MyStruct rhs) - { - return new MyStruct(lhs.value - rhs.value); - } - - public static MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) - { - return Subtract(lhs, rhs); - } - } -} -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ThisTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; - - int MyFunction() - { - return this->value; - } -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - - public int MyFunction() - { - return this.value; - } - } -} -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnsafeDoesNotImpactDllImportTestImpl() - { - var inputContents = @"struct MyStruct -{ - void* MyVoidStarMethod() - { - return nullptr; - } -}; - -extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - public void* MyVoidStarMethod() - { - return null; - } - } - - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationTest.cs deleted file mode 100644 index 6e81b3a5..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -public abstract class CXXMethodDeclarationTest : PInvokeGeneratorTest -{ - [Test] - public Task ConstructorTest() => ConstructorTestImpl(); - - [Test] - public Task ConstructorWithInitializeTest() => ConstructorWithInitializeTestImpl(); - - [Test] - public Task ConversionTest() => ConversionTestImpl(); - - [Test] - public Task DefaultParameterInheritedFromTemplateTest() => DefaultParameterInheritedFromTemplateTestImpl(); - - [Test] - public Task DestructorTest() => DestructorTestImpl(); - - [Test] - public Task InstanceTest() => InstanceTestImpl(); - - [Test] - public Task MacrosExpansionTest() => MacrosExpansionTestImpl(); - - [Test] - public Task MemberCallTest() => MemberCallTestImpl(); - - [Test] - public Task MemberTest() => MemberTestImpl(); - - [Test] - public Task NewKeywordTest() => NewKeywordTestImpl(); - - [Test] - public Task NewKeywordVirtualTest() => NewKeywordVirtualTestImpl(); - - [Test] - public Task NewKeywordVirtualWithExplicitVtblTest() => NewKeywordVirtualWithExplicitVtblTestImpl(); - - [Test] - public Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest() => NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl(); - - [Test] - public Task OperatorTest() => OperatorTestImpl(); - - [Test] - public Task OperatorCallTest() => OperatorCallTestImpl(); - - [Test] - public Task StaticTest() => StaticTestImpl(); - - [Test] - public Task ThisTest() => ThisTestImpl(); - - [Test] - public Task UnsafeDoesNotImpactDllImportTest() => UnsafeDoesNotImpactDllImportTestImpl(); - - [Test] - public Task VirtualTest() => VirtualTestImpl(); - - [Test] - public Task VirtualWithVtblIndexAttributeTest() => VirtualWithVtblIndexAttributeTestImpl(); - - protected abstract Task ConstructorTestImpl(); - - protected abstract Task ConstructorWithInitializeTestImpl(); - - protected abstract Task ConversionTestImpl(); - - protected abstract Task DefaultParameterInheritedFromTemplateTestImpl(); - - protected abstract Task DestructorTestImpl(); - - protected abstract Task InstanceTestImpl(); - - protected abstract Task MacrosExpansionTestImpl(); - - protected abstract Task MemberCallTestImpl(); - - protected abstract Task MemberTestImpl(); - - protected abstract Task NewKeywordTestImpl(); - - protected abstract Task NewKeywordVirtualTestImpl(); - - protected abstract Task NewKeywordVirtualWithExplicitVtblTestImpl(); - - protected abstract Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl(); - - protected abstract Task OperatorTestImpl(); - - protected abstract Task OperatorCallTestImpl(); - - protected abstract Task StaticTestImpl(); - - protected abstract Task ThisTestImpl(); - - protected abstract Task UnsafeDoesNotImpactDllImportTestImpl(); - - protected abstract Task VirtualTestImpl(); - - protected abstract Task VirtualWithVtblIndexAttributeTestImpl(); - - protected abstract Task ValidateBindingsAsync(string inputContents, string expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationXmlTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationXmlTest.cs deleted file mode 100644 index 0a37bdf1..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/CXXMethodDeclarationXmlTest.cs +++ /dev/null @@ -1,676 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; - -namespace ClangSharp.UnitTests; - -public abstract class CXXMethodDeclarationXmlTest: CXXMethodDeclarationTest -{ - protected override Task ConstructorTestImpl() - { - var inputContents = @"struct MyStruct -{ - int _value; - - MyStruct(int value) - { - _value = value; - } -}; -"; - - var expectedOutputContents = @" - - - - - int - - - void - - int - - _value = value; - - - - -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConstructorWithInitializeTestImpl() - { - var inputContents = @"struct MyStruct -{ - int _x; - int _y; - int _z; - - MyStruct(int x) : _x(x) - { - } - - MyStruct(int x, int y) : _x(x), _y(y) - { - } - - MyStruct(int x, int y, int z) : _x(x), _y(y), _z() - { - } -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - int - - - void - - int - - - x - - - - - void - - int - - - int - - - x - - - y - - - - - void - - int - - - int - - - int - - - x - - - y - - - - - - -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConversionTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; - - operator int() - { - return value; - } -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - return value; - - - - -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DestructorTestImpl() - { - var inputContents = @"struct MyStruct -{ - ~MyStruct() - { - } -}; -"; - - var expectedOutputContents = @" - - - - - void - - - - - -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MacrosExpansionTestImpl() - { - var inputContents = @"typedef struct -{ - unsigned char *buf; - int size; -} context_t; - -int buf_close(void *pcontext) -{ - ((context_t*)pcontext)->buf=0; - return 0; -} -"; - - var expectedOutputContents = @" - - - - - byte* - - - int - - - - - int - - void* - - ((context_t*)(pcontext))->buf = null; - return 0; - - - - -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberCallTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; - - int MyFunction1() - { - return value; - } - - int MyFunction2() - { - return MyFunction1(); - } - - int MyFunction3() - { - return this->MyFunction1(); - } -}; - -int MyFunctionA(MyStruct x) -{ - return x.MyFunction1(); -} - -int MyFunctionB(MyStruct* x) -{ - return x->MyFunction2(); -} -"; - - var expectedOutputContents = @" - - - - - int - - - int - return value; - - - int - return MyFunction1(); - - - int - return this.MyFunction1(); - - - - - int - - MyStruct - - return x.MyFunction1(); - - - int - - MyStruct* - - return x->MyFunction2(); - - - - -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; - - int MyFunction() - { - return value; - } -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - return value; - - - - -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals() { return 0; } - int Equals(int obj) { return 0; } - int Dispose() { return 0; } - int Dispose(int obj) { return 0; } - int GetHashCode() { return 0; } - int GetHashCode(int obj) { return 0; } - int GetType() { return 0; } - int GetType(int obj) { return 0; } - int MemberwiseClone() { return 0; } - int MemberwiseClone(int obj) { return 0; } - int ReferenceEquals() { return 0; } - int ReferenceEquals(int obj) { return 0; } - int ToString() { return 0; } - int ToString(int obj) { return 0; } -};"; - - var expectedOutputContents = $@" - - - - - int - return 0; - - - int - - int - - return 0; - - - int - return 0; - - - int - - int - - return 0; - - - int - return 0; - - - int - - int - - return 0; - - - int - return 0; - - - int - - int - - return 0; - - - int - return 0; - - - int - - int - - return 0; - - - int - return 0; - - - int - - int - - return 0; - - - int - return 0; - - - int - - int - - return 0; - - - - -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OperatorTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; - - MyStruct(int value) : value(value) - { - } - - MyStruct operator+(MyStruct rhs) - { - return MyStruct(value + rhs.value); - } -}; - -MyStruct operator-(MyStruct lhs, MyStruct rhs) -{ - return MyStruct(lhs.value - rhs.value); -} -"; - - var expectedOutputContents = @" - - - - - int - - - void - - int - - - value - - - - - MyStruct - - MyStruct - - return new MyStruct(value + rhs.value); - - - - - MyStruct - - MyStruct - - - MyStruct - - return new MyStruct(lhs.value - rhs.value); - - - - -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OperatorCallTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; - - MyStruct(int value) : value(value) - { - } - - MyStruct operator+(MyStruct rhs) - { - return MyStruct(value + rhs.value); - } -}; - -MyStruct MyFunction1(MyStruct lhs, MyStruct rhs) -{ - return lhs + rhs; -} - -MyStruct operator-(MyStruct lhs, MyStruct rhs) -{ - return MyStruct(lhs.value - rhs.value); -} - -MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) -{ - return lhs - rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - - void - - int - - - value - - - - - MyStruct - - MyStruct - - return new MyStruct(value + rhs.value); - - - - - MyStruct - - MyStruct - - - MyStruct - - return lhs.Add(rhs); - - - MyStruct - - MyStruct - - - MyStruct - - return new MyStruct(lhs.value - rhs.value); - - - MyStruct - - MyStruct - - - MyStruct - - return Subtract(lhs, rhs); - - - - -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ThisTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; - - int MyFunction() - { - return this->value; - } -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - return this.value; - - - - -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnsafeDoesNotImpactDllImportTestImpl() - { - var inputContents = @"struct MyStruct -{ - void* MyVoidStarMethod() - { - return nullptr; - } -}; - -extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void* - return null; - - - - - void - - - - -"; - - return ValidateBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/DeprecatedToObsoleteTest.cs deleted file mode 100644 index f062c262..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -public abstract class DeprecatedToObsoleteTest : PInvokeGeneratorTest -{ - [TestCase("int", "int")] - public Task SimpleStructMembers(string nativeType, string expectedManagedType) => SimpleStructMembersImpl(nativeType, expectedManagedType); - - [Test] - public Task StructDecl() => StructDeclImpl(); - - [TestCase("int", "int")] - public Task SimpleTypedefStructMembers(string nativeType, string expectedManagedType) => SimpleTypedefStructMembersImpl(nativeType, expectedManagedType); - - [Test] - public Task TypedefStructDecl() => TypedefStructDeclImpl(); - - [Test] - public Task SimpleEnumMembers() => SimpleEnumMembersImpl(); - - [Test] - public Task EnumDecl() => EnumDeclImpl(); - - [TestCase("int", "int")] - public Task SimpleVarDecl(string nativeType, string expectedManagedType) => SimpleVarDeclImpl(nativeType, expectedManagedType); - - [Test] - public Task FuncDecl() => FuncDeclImpl(); - - [Test] - public Task InstanceFunc() => InstanceFuncImpl(); - - [Test] - public Task FuncPtrDecl() => FuncPtrDeclImpl(); - - [Test] - public Task FuncDeclDllImport() => FuncDllImportImpl(); - - protected abstract Task SimpleStructMembersImpl(string nativeType, string expectedManagedType); - - protected abstract Task StructDeclImpl(); - - protected abstract Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType); - - protected abstract Task TypedefStructDeclImpl(); - - protected abstract Task SimpleEnumMembersImpl(); - - protected abstract Task EnumDeclImpl(); - - protected abstract Task SimpleVarDeclImpl(string nativeType, string expectedManagedType); - - protected abstract Task FuncDeclImpl(); - - protected abstract Task InstanceFuncImpl(); - - protected abstract Task FuncPtrDeclImpl(); - - protected abstract Task FuncDllImportImpl(); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/DigitsSeparatorTest.cs deleted file mode 100644 index baffbb92..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/DigitsSeparatorTest.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -public abstract class DigitsSeparatorTest : PInvokeGeneratorTest -{ - [TestCase("int", "1'024", "1_024")] - [TestCase("int", "1'000'001", "1_000_001")] - [TestCase("float", "1'024", "1_024")] - [TestCase("float", "1'024.0", "1_024.0")] - public Task StaticConstExprTest(string type, string nativeValue, string expectedValue) => StaticConstExprTestImpl(type, nativeValue, expectedValue); - - protected abstract Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/EnumDeclarationTest.cs deleted file mode 100644 index 1048a150..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/EnumDeclarationTest.cs +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -public abstract class EnumDeclarationTest : PInvokeGeneratorTest -{ - protected static readonly string[] ExcludeTestExcludedNames = ["MyEnum"]; - - [Test] - public Task BasicTest() => BasicTestImpl(); - - [Test] - public Task BasicValueTest() => BasicValueTestImpl(); - - [Test] - public Task ExcludeTest() => ExcludeTestImpl(); - - [TestCase("short", "short")] - public Task ExplicitTypedTest(string nativeType, string expectedManagedType) => ExplicitTypedTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - public Task ExplicitTypedWithNativeTypeNameTest(string nativeType, string expectedManagedType) => ExplicitTypedWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [Test] - public Task RemapTest() => RemapTestImpl(); - - [Test] - public Task WithAttributeTest() => WithAttributeTestImpl(); - - [Test] - public Task WithNamespaceTest() => WithNamespaceTestImpl(); - - [Test] - public Task WithNamespaceStarTest() => WithNamespaceStarTestImpl(); - - [Test] - public Task WithNamespaceStarPlusTest() => WithNamespaceStarPlusTestImpl(); - - [Test] - public Task WithCastToEnumType() => WithCastToEnumTypeImpl(); - - [Test] - public Task WithMultipleEnumsTest() => WithMultipleEnumsTestImpl(); - - [Test] - public Task WithImplicitConversionTest() => WithImplicitConversionTestImpl(); - - [Test] - public Task WithTypeTest() => WithTypeTestImpl(); - - [Test] - public Task WithTypeAndImplicitConversionTest() => WithTypeAndImplicitConversionTestImpl(); - - [Test] - public Task WithTypeStarTest() => WithTypeStarTestImpl(); - - [Test] - public Task WithTypeStarOverrideTest() => WithTypeStarOverrideTestImpl(); - - [Test] - public Task WithAnonymousEnumTest() => WithAnonymousEnumTestImpl(); - - [Test] - public Task WithReferenceToAnonymousEnumEnumeratorTest() => WithReferenceToAnonymousEnumEnumeratorTestImpl(); - - protected abstract Task BasicTestImpl(); - - protected abstract Task BasicValueTestImpl(); - - protected abstract Task ExcludeTestImpl(); - - protected abstract Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - - - protected abstract Task RemapTestImpl(); - - protected abstract Task WithAttributeTestImpl(); - - protected abstract Task WithNamespaceTestImpl(); - - protected abstract Task WithNamespaceStarTestImpl(); - - protected abstract Task WithNamespaceStarPlusTestImpl(); - - protected abstract Task WithCastToEnumTypeImpl(); - - protected abstract Task WithMultipleEnumsTestImpl(); - - protected abstract Task WithImplicitConversionTestImpl(); - - protected abstract Task WithTypeTestImpl(); - - protected abstract Task WithTypeAndImplicitConversionTestImpl(); - - protected abstract Task WithTypeStarTestImpl(); - - protected abstract Task WithTypeStarOverrideTestImpl(); - - protected abstract Task WithAnonymousEnumTestImpl(); - - protected abstract Task WithReferenceToAnonymousEnumEnumeratorTestImpl(); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index 52727f75..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -public abstract class FunctionDeclarationBodyImportTest : PInvokeGeneratorTest -{ - [Test] - public Task AccessUnionMemberTest() => AccessUnionMemberTestImpl(); - - [Test] - public Task ArraySubscriptTest() => ArraySubscriptTestImpl(); - - [Test] - public Task BasicTest() => BasicTestImpl(); - - [TestCase("%")] - [TestCase("%=")] - [TestCase("&")] - [TestCase("&=")] - [TestCase("*")] - [TestCase("*=")] - [TestCase("+")] - [TestCase("+=")] - [TestCase("-")] - [TestCase("-=")] - [TestCase("/")] - [TestCase("/=")] - [TestCase("<<")] - [TestCase("<<=")] - [TestCase("=")] - [TestCase(">>")] - [TestCase(">>=")] - [TestCase("^")] - [TestCase("^=")] - [TestCase("|")] - [TestCase("|=")] - public Task BinaryOperatorBasicTest(string opcode) => BinaryOperatorBasicTestImpl(opcode); - - [TestCase("==")] - [TestCase("!=")] - [TestCase("<")] - [TestCase("<=")] - [TestCase(">")] - [TestCase(">=")] - public Task BinaryOperatorCompareTest(string opcode) => BinaryOperatorCompareTestImpl(opcode); - - [TestCase("&&")] - [TestCase("||")] - public Task BinaryOperatorBooleanTest(string opcode) => BinaryOperatorBooleanTestImpl(opcode); - - [Test] - public Task BreakTest() => BreakTestImpl(); - - [Test] - public Task CallFunctionTest() => CallFunctionTestImpl(); - - [Test] - public Task CallFunctionWithArgsTest() => CallFunctionWithArgsTestImpl(); - - [Test] - public Task CaseTest() => CaseTestImpl(); - - [Test] - public Task CaseNoCompoundTest() => CaseNoCompoundTestImpl(); - - [Test] - public Task CompareMultipleEnumTest() => CompareMultipleEnumTestImpl(); - - [Test] - public Task ConditionalOperatorTest() => ConditionalOperatorTestImpl(); - - [Test] - public Task ContinueTest() => ContinueTestImpl(); - - [Test] - public Task CStyleFunctionalCastTest() => CStyleFunctionalCastTestImpl(); - - [Test] - public Task CxxFunctionalCastTest() => CxxFunctionalCastTestImpl(); - - [Test] - public Task CxxConstCastTest() => CxxConstCastTestImpl(); - - [Test] - public Task CxxDynamicCastTest() => CxxDynamicCastTestImpl(); - - [Test] - public Task CxxReinterpretCastTest() => CxxReinterpretCastTestImpl(); - - [Test] - public Task CxxStaticCastTest() => CxxStaticCastTestImpl(); - - [Test] - public Task DeclTest() => DeclTestImpl(); - - [Test] - public Task DoTest() => DoTestImpl(); - - [Test] - public Task DoNonCompoundTest() => DoNonCompoundTestImpl(); - - [Test] - public Task ForTest() => ForTestImpl(); - - [Test] - public Task ForNonCompoundTest() => ForNonCompoundTestImpl(); - - [Test] - public Task IfTest() => IfTestImpl(); - - [Test] - public Task IfElseTest() => IfElseTestImpl(); - - [Test] - public Task IfElseIfTest() => IfElseIfTestImpl(); - - [Test] - public Task IfElseNonCompoundTest() => IfElseNonCompoundTestImpl(); - - [Test] - public Task InitListForArrayTest() => InitListForArrayTestImpl(); - - [Test] - public Task InitListForRecordDeclTest() => InitListForRecordDeclTestImpl(); - - [Test] - public Task MemberTest() => MemberTestImpl(); - - [Test] - public Task RefToPtrTest() => RefToPtrTestImpl(); - - [Test] - public Task ReturnCXXNullPtrTest() => ReturnCXXNullPtrTestImpl(); - - [TestCase("false")] - [TestCase("true")] - public Task ReturnCXXBooleanLiteralTest(string value) => ReturnCXXBooleanLiteralTestImpl(value); - - [TestCase("5e-1")] - [TestCase("3.14")] - public Task ReturnFloatingLiteralDoubleTest(string value) => ReturnFloatingLiteralDoubleTestImpl(value); - - [TestCase("5e-1f")] - [TestCase("3.14f")] - public Task ReturnFloatingLiteralSingleTest(string value) => ReturnFloatingLiteralSingleTestImpl(value); - - [Test] - public Task ReturnEmptyTest() => ReturnEmptyTestImpl(); - - [Test] - public Task ReturnIntegerLiteralInt32Test() => ReturnIntegerLiteralInt32TestImpl(); - - [Test] - public Task ReturnStructTest() => ReturnStructTestImpl(); - - [Test] - public Task SwitchTest() => SwitchTestImpl(); - - [Test] - public Task SwitchNonCompoundTest() => SwitchNonCompoundTestImpl(); - - [Test] - public Task UnaryOperatorAddrOfTest() => UnaryOperatorAddrOfTestImpl(); - - [Test] - public Task UnaryOperatorDerefTest() => UnaryOperatorDerefTestImpl(); - - [Test] - public Task UnaryOperatorLogicalNotTest() => UnaryOperatorLogicalNotTestImpl(); - - [TestCase("++")] - [TestCase("--")] - public Task UnaryOperatorPostfixTest(string opcode) => UnaryOperatorPostfixTestImpl(opcode); - - [TestCase("+")] - [TestCase("++")] - [TestCase("-")] - [TestCase("--")] - [TestCase("~")] - public Task UnaryOperatorPrefixTest(string opcode) => UnaryOperatorPrefixTestImpl(opcode); - - [Test] - public Task WhileTest() => WhileTestImpl(); - - [Test] - public Task WhileNonCompoundTest() => WhileNonCompoundTestImpl(); - - protected abstract Task AccessUnionMemberTestImpl(); - - protected abstract Task ArraySubscriptTestImpl(); - - protected abstract Task BasicTestImpl(); - - protected abstract Task BinaryOperatorBasicTestImpl(string opcode); - - protected abstract Task BinaryOperatorCompareTestImpl(string opcode); - - protected abstract Task BinaryOperatorBooleanTestImpl(string opcode); - - protected abstract Task BreakTestImpl(); - - protected abstract Task CallFunctionTestImpl(); - - protected abstract Task CallFunctionWithArgsTestImpl(); - - protected abstract Task CaseTestImpl(); - - protected abstract Task CaseNoCompoundTestImpl(); - - protected abstract Task CompareMultipleEnumTestImpl(); - - protected abstract Task ConditionalOperatorTestImpl(); - - protected abstract Task ContinueTestImpl(); - - protected abstract Task CStyleFunctionalCastTestImpl(); - - protected abstract Task CxxFunctionalCastTestImpl(); - - protected abstract Task CxxConstCastTestImpl(); - - protected abstract Task CxxDynamicCastTestImpl(); - - protected abstract Task CxxReinterpretCastTestImpl(); - - protected abstract Task CxxStaticCastTestImpl(); - - protected abstract Task DeclTestImpl(); - - protected abstract Task DoTestImpl(); - - protected abstract Task DoNonCompoundTestImpl(); - - protected abstract Task ForTestImpl(); - - protected abstract Task ForNonCompoundTestImpl(); - - protected abstract Task IfTestImpl(); - - protected abstract Task IfElseTestImpl(); - - protected abstract Task IfElseIfTestImpl(); - - protected abstract Task IfElseNonCompoundTestImpl(); - - protected abstract Task InitListForArrayTestImpl(); - - protected abstract Task InitListForRecordDeclTestImpl(); - - protected abstract Task MemberTestImpl(); - - protected abstract Task RefToPtrTestImpl(); - - protected abstract Task ReturnCXXNullPtrTestImpl(); - - protected abstract Task ReturnCXXBooleanLiteralTestImpl(string value); - - protected abstract Task ReturnFloatingLiteralDoubleTestImpl(string value); - - protected abstract Task ReturnFloatingLiteralSingleTestImpl(string value); - - protected abstract Task ReturnEmptyTestImpl(); - - protected abstract Task ReturnIntegerLiteralInt32TestImpl(); - - protected abstract Task ReturnStructTestImpl(); - - protected abstract Task SwitchTestImpl(); - - protected abstract Task SwitchNonCompoundTestImpl(); - - protected abstract Task UnaryOperatorAddrOfTestImpl(); - - protected abstract Task UnaryOperatorDerefTestImpl(); - - protected abstract Task UnaryOperatorLogicalNotTestImpl(); - - protected abstract Task UnaryOperatorPostfixTestImpl(string opcode); - - protected abstract Task UnaryOperatorPrefixTestImpl(string opcode); - - protected abstract Task WhileTestImpl(); - - protected abstract Task WhileNonCompoundTestImpl(); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index 763a04f9..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -public abstract class FunctionDeclarationDllImportTest : PInvokeGeneratorTest -{ - protected static readonly string[] TemplateTestExcludedNames = ["MyTemplate"]; - - [Test] - public Task BasicTest() => BasicTestImpl(); - - [Test] - public Task ArrayParameterTest() => ArrayParameterTestImpl(); - - [Test] - public Task FunctionPointerParameterTest() => FunctionPointerParameterTestImpl(); - - [Test] - public Task NamespaceTest() => NamespaceTestImpl(); - - [TestCase("int", false, "int", "")] - [TestCase("bool", true, "byte", "")] - [TestCase("float *", true, "IntPtr", "using System;\n")] - [TestCase("void (*)(int)", true, "IntPtr", "using System;\n")] - public Task TemplateParameterTest(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) => TemplateParameterTestImpl(nativeType, expectedNativeTypeAttr, expectedManagedType, expectedUsingStatement); - - [Test] - public Task TemplateMemberTest() => TemplateMemberTestImpl(); - - - [Test] - public Task NoLibraryPathTest() => NoLibraryPathTestImpl(); - - [Test] - public Task WithLibraryPathTest() => WithLibraryPathTestImpl(); - - [Test] - public Task WithLibraryPathStarTest() => WithLibraryPathStarTestImpl(); - - [TestCase("unsigned char", "0", true, "byte", "0")] - [TestCase("double", "1.0", false, "double", "1.0")] - [TestCase("short", "2", false, "short", "2")] - [TestCase("int", "3", false, "int", "3")] - [TestCase("long long", "4", true, "long", "4")] - [TestCase("signed char", "5", true, "sbyte", "5")] - [TestCase("float", "6.0f", false, "float", "6.0f")] - [TestCase("unsigned short", "7", true, "ushort", "7")] - [TestCase("unsigned int", "8", true, "uint", "8")] - [TestCase("unsigned long long", "9", true, "ulong", "9")] - [TestCase("unsigned short", "'A'", true, "ushort", "(byte)('A')")] - public Task OptionalParameterTest(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) => OptionalParameterTestImpl(nativeType, nativeInit, expectedNativeTypeNameAttr, expectedManagedType, expectedManagedInit); - - [TestCase("void *", "nullptr", "void*", "null")] - [TestCase("void *", "0", "void*", "null")] - public Task OptionalParameterUnsafeTest(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) => OptionalParameterUnsafeTestImpl(nativeType, nativeInit, expectedManagedType, expectedManagedInit); - - [Test] - public Task WithCallConvTest() => WithCallConvTestImpl(); - - [Test] - public Task WithCallConvStarTest() => WithCallConvStarTestImpl(); - - [Test] - public Task WithCallConvStarOverrideTest() => WithCallConvStarOverrideTestImpl(); - - [Test] - public Task WithSetLastErrorTest() => WithSetLastErrorTestImpl(); - - [Test] - public Task WithSetLastErrorStarTest() => WithSetLastErrorStarTestImpl(); - - [Test] - public Task SourceLocationTest() => SourceLocationTestImpl(); - - [Test] - public Task VarargsTest() => VarargsTestImpl(); - - [Test] - public Task IntrinsicsTest() => IntrinsicsTestImpl(); - - protected abstract Task BasicTestImpl(); - - protected abstract Task ArrayParameterTestImpl(); - - protected abstract Task FunctionPointerParameterTestImpl(); - - protected abstract Task NamespaceTestImpl(); - - protected abstract Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement); - - protected abstract Task TemplateMemberTestImpl(); - - protected abstract Task NoLibraryPathTestImpl(); - - protected abstract Task WithLibraryPathTestImpl(); - - protected abstract Task WithLibraryPathStarTestImpl(); - - protected abstract Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit); - - protected abstract Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit); - - protected abstract Task WithCallConvTestImpl(); - - protected abstract Task WithCallConvStarTestImpl(); - - protected abstract Task WithCallConvStarOverrideTestImpl(); - - protected abstract Task WithSetLastErrorTestImpl(); - - protected abstract Task WithSetLastErrorStarTestImpl(); - - protected abstract Task SourceLocationTestImpl(); - - protected abstract Task VarargsTestImpl(); - - protected abstract Task IntrinsicsTestImpl(); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionPointerDeclarationTest.cs deleted file mode 100644 index 7938c6b1..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -public abstract class FunctionPointerDeclarationTest : PInvokeGeneratorTest -{ - [Test] - public Task BasicTest() => BasicTestImpl(); - - [Test] - public Task CallconvTest() => CallconvTestImpl(); - - [Test] - public Task PointerlessTypedefTest() => PointerlessTypedefTestImpl(); - - protected abstract Task BasicTestImpl(); - - protected abstract Task CallconvTestImpl(); - - protected abstract Task PointerlessTypedefTestImpl(); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs deleted file mode 100644 index 8561f15f..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/StructDeclarationTest.cs +++ /dev/null @@ -1,312 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -public abstract class StructDeclarationTest : PInvokeGeneratorTest -{ - protected static readonly string[] ExcludeTestExcludedNames = ["MyStruct"]; - protected static readonly string[] GuidTestExcludedNames = ["DECLSPEC_UUID"]; - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task IncompleteArraySizeTest(string nativeType, string expectedManagedType) => IncompleteArraySizeTestImpl(nativeType, expectedManagedType); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task BasicTest(string nativeType, string expectedManagedType) => BasicTestImpl(nativeType, expectedManagedType); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task BasicTestInCMode(string nativeType, string expectedManagedType) => BasicTestInCModeImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task BasicWithNativeTypeNameTest(string nativeType, string expectedManagedType) => BasicWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [Test] - public Task BitfieldTest() => BitfieldTestImpl(); - - [Test] - public Task BitfieldWithNativeBitfieldAttributeTest() => BitfieldWithNativeBitfieldAttributeTestImpl(); - - [Test] - public Task DeclTypeTest() => DeclTypeTestImpl(); - - [Test] - public Task ExcludeTest() => ExcludeTestImpl(); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task FixedSizedBufferNonPrimitiveTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveTestImpl(nativeType, expectedManagedType); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task FixedSizedBufferNonPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(nativeType, expectedManagedType); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task FixedSizedBufferNonPrimitiveTypedefTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveTypedefTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [TestCase("double *", "double*")] - [TestCase("short *", "short*")] - [TestCase("int *", "int*")] - [TestCase("float *", "float*")] - public Task FixedSizedBufferPointerTest(string nativeType, string expectedManagedType) => FixedSizedBufferPointerTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - public Task FixedSizedBufferPrimitiveTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - public Task FixedSizedBufferPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveMultidimensionalTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - public Task FixedSizedBufferPrimitiveTypedefTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTypedefTestImpl(nativeType, expectedManagedType); - - [Test] - public Task GuidTest() => GuidTestImpl(); - - [Test] - public Task InheritanceTest() => InheritanceTestImpl(); - - [Test] - public Task InheritanceWithNativeInheritanceAttributeTest() => InheritanceWithNativeInheritanceAttributeTestImpl(); - - [TestCase("double", "double", 10, 5)] - [TestCase("short", "short", 10, 5)] - [TestCase("int", "int", 10, 5)] - [TestCase("float", "float", 10, 5)] - public Task NestedAnonymousTest(string nativeType, string expectedManagedType, int line, int column) => NestedAnonymousTestImpl(nativeType, expectedManagedType, line, column); - - [Test] - public Task NestedAnonymousWithBitfieldTest() => NestedAnonymousWithBitfieldTestImpl(); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task NestedTest(string nativeType, string expectedManagedType) => NestedTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task NestedWithNativeTypeNameTest(string nativeType, string expectedManagedType) => NestedWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [Test] - public Task NewKeywordTest() => NewKeywordTestImpl(); - - [Test] - public Task NoDefinitionTest() => NoDefinitionTestImpl(); - - [Test] - public Task PackTest() => PackTestImpl(); - - [Test] - public Task PointerToSelfTest() => PointerToSelfTestImpl(); - - [Test] - public Task PointerToSelfViaTypedefTest() => PointerToSelfViaTypedefTestImpl(); - - [Test] - public Task RemapTest() => RemapTestImpl(); - - [Test] - public Task RemapNestedAnonymousTest() => RemapNestedAnonymousTestImpl(); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task SkipNonDefinitionTest(string nativeType, string expectedManagedType) => SkipNonDefinitionTestImpl(nativeType, expectedManagedType); - - [Test] - public Task SkipNonDefinitionPointerTest() => SkipNonDefinitionPointerTestImpl(); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task SkipNonDefinitionWithNativeTypeNameTest(string nativeType, string expectedManagedType) => SkipNonDefinitionWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task TypedefTest(string nativeType, string expectedManagedType) => TypedefTestImpl(nativeType, expectedManagedType); - - [Test] - public Task UsingDeclarationTest() => UsingDeclarationTestImpl(); - - [Test] - public Task WithAccessSpecifierTest() => WithAccessSpecifierTestImpl(); - - [Test] - public Task WithPackingTest() => WithPackingTestImpl(); - - [Test] - public Task SourceLocationAttributeTest() => SourceLocationAttributeTestImpl(); - - // Regression test: the code that generated the name for anonymous types had a couple of - // bugs: - // * It would only append a numeral if the parent had more than one anonymous records, - // but an anonymous typed array didn't count as a record resulting in multiple structs - // named `_Anonymous_e__Struct`. - // * The code that remapped the name of anonymous types was different between the code that - // generated the type definition and the code that defined fields in a FixedBuffer. - [Test] - public Task AnonStructAndAnonStructArray() => AnonStructAndAnonStructArrayImpl(); - - // Regression test: nested anonymous structs would result in: - // error CS0542: '_Anonymous_e__Struct': member names cannot be the same as their enclosing type - [Test] - public Task DeeplyNestedAnonStructs() => DeeplyNestedAnonStructsImpl(); - - protected abstract Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task BasicTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task BasicTestInCModeImpl(string nativeType, string expectedManagedType); - - protected abstract Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task BitfieldTestImpl(); - - protected abstract Task BitfieldWithNativeBitfieldAttributeTestImpl(); - - protected abstract Task DeclTypeTestImpl(); - - protected abstract Task ExcludeTestImpl(); - - protected abstract Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task GuidTestImpl(); - - protected abstract Task InheritanceTestImpl(); - - protected abstract Task InheritanceWithNativeInheritanceAttributeTestImpl(); - - protected abstract Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column); - - protected abstract Task NestedAnonymousWithBitfieldTestImpl(); - - protected abstract Task NestedTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task NewKeywordTestImpl(); - - protected abstract Task NoDefinitionTestImpl(); - - protected abstract Task PackTestImpl(); - - protected abstract Task PointerToSelfTestImpl(); - - protected abstract Task PointerToSelfViaTypedefTestImpl(); - - protected abstract Task RemapTestImpl(); - - protected abstract Task RemapNestedAnonymousTestImpl(); - - protected abstract Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task SkipNonDefinitionPointerTestImpl(); - - protected abstract Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task TypedefTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task UsingDeclarationTestImpl(); - - protected abstract Task WithAccessSpecifierTestImpl(); - - protected abstract Task WithPackingTestImpl(); - - protected abstract Task SourceLocationAttributeTestImpl(); - - protected abstract Task AnonStructAndAnonStructArrayImpl(); - - protected abstract Task DeeplyNestedAnonStructsImpl(); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs deleted file mode 100644 index f6ff2143..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/UnionDeclarationTest.cs +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -public abstract class UnionDeclarationTest : PInvokeGeneratorTest -{ - protected static readonly string[] ExcludeTestExcludedNames = ["MyUnion"]; - protected static readonly string[] GuidTestExcludedNames = ["DECLSPEC_UUID"]; - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task BasicTest(string nativeType, string expectedManagedType) => BasicTestImpl(nativeType, expectedManagedType); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task BasicTestInCMode(string nativeType, string expectedManagedType) => BasicTestInCModeImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task BasicWithNativeTypeNameTest(string nativeType, string expectedManagedType) => BasicWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [Test] - public Task BitfieldTest() => BitfieldTestImpl(); - - [Test] - public Task ExcludeTest() => ExcludeTestImpl(); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task FixedSizedBufferNonPrimitiveTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveTestImpl(nativeType, expectedManagedType); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task FixedSizedBufferNonPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(nativeType, expectedManagedType); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task FixedSizedBufferNonPrimitiveTypedefTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveTypedefTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTest(string nativeType, string expectedManagedType) => FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [TestCase("double *", "double*")] - [TestCase("short *", "short*")] - [TestCase("int *", "int*")] - [TestCase("float *", "float*")] - public Task FixedSizedBufferPointerTest(string nativeType, string expectedManagedType) => FixedSizedBufferPointerTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - public Task FixedSizedBufferPrimitiveTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - public Task FixedSizedBufferPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveMultidimensionalTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - public Task FixedSizedBufferPrimitiveTypedefTest(string nativeType, string expectedManagedType) => FixedSizedBufferPrimitiveTypedefTestImpl(nativeType, expectedManagedType); - - [Test] - public Task GuidTest() => GuidTestImpl(); - - [TestCase("double", "double", 11, 5)] - [TestCase("short", "short", 11, 5)] - [TestCase("int", "int", 11, 5)] - [TestCase("float", "float", 11, 5)] - public Task NestedAnonymousTest(string nativeType, string expectedManagedType, int line, int column) => NestedAnonymousTestImpl(nativeType, expectedManagedType, line, column); - - [Test] - public Task NestedAnonymousWithBitfieldTest() => NestedAnonymousWithBitfieldTestImpl(); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task NestedTest(string nativeType, string expectedManagedType) => NestedTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task NestedWithNativeTypeNameTest(string nativeType, string expectedManagedType) => NestedWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [Test] - public Task NewKeywordTest() => NewKeywordTestImpl(); - - [Test] - public Task NoDefinitionTest() => NoDefinitionTestImpl(); - - [Test] - public Task PointerToSelfTest() => PointerToSelfTestImpl(); - - [Test] - public Task PointerToSelfViaTypedefTest() => PointerToSelfViaTypedefTestImpl(); - - [Test] - public Task RemapTest() => RemapTestImpl(); - - [Test] - public Task RemapNestedAnonymousTest() => RemapNestedAnonymousTestImpl(); - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task SkipNonDefinitionTest(string nativeType, string expectedManagedType) => SkipNonDefinitionTestImpl(nativeType, expectedManagedType); - - [Test] - public Task SkipNonDefinitionPointerTest() => SkipNonDefinitionPointerTestImpl(); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task SkipNonDefinitionWithNativeTypeNameTest(string nativeType, string expectedManagedType) => SkipNonDefinitionWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("float", "float")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - [TestCase("bool", "byte")] - public Task TypedefTest(string nativeType, string expectedManagedType) => TypedefTestImpl(nativeType, expectedManagedType); - - [Test] - public Task UnionWithAnonStructWithAnonUnion() => UnionWithAnonStructWithAnonUnionImpl(); - - protected abstract Task BasicTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task BasicTestInCModeImpl(string nativeType, string expectedManagedType); - - protected abstract Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task BitfieldTestImpl(); - - protected abstract Task ExcludeTestImpl(); - - protected abstract Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task GuidTestImpl(); - - protected abstract Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column); - - protected abstract Task NestedAnonymousWithBitfieldTestImpl(); - - protected abstract Task NestedTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task NewKeywordTestImpl(); - - protected abstract Task NoDefinitionTestImpl(); - - protected abstract Task PointerToSelfTestImpl(); - - protected abstract Task PointerToSelfViaTypedefTestImpl(); - - protected abstract Task RemapTestImpl(); - - protected abstract Task RemapNestedAnonymousTestImpl(); - - protected abstract Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task SkipNonDefinitionPointerTestImpl(); - - protected abstract Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task TypedefTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task UnionWithAnonStructWithAnonUnionImpl(); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs deleted file mode 100644 index 2cc3ea7e..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Base/VarDeclarationTest.cs +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -public abstract class VarDeclarationTest : PInvokeGeneratorTest -{ - protected static readonly string[] GuidMacroTestExcludedNames = ["GUID"]; - protected static readonly string[] UncheckedConversionMacroTest2ExcludedNames = ["MyMacro1", "MyMacro2"]; - - [TestCase("double", "double")] - [TestCase("short", "short")] - [TestCase("int", "int")] - [TestCase("float", "float")] - public Task BasicTest(string nativeType, string expectedManagedType) => BasicTestImpl(nativeType, expectedManagedType); - - [TestCase("unsigned char", "byte")] - [TestCase("long long", "long")] - [TestCase("signed char", "sbyte")] - [TestCase("unsigned short", "ushort")] - [TestCase("unsigned int", "uint")] - [TestCase("unsigned long long", "ulong")] - public Task BasicWithNativeTypeNameTest(string nativeType, string expectedManagedType) => BasicWithNativeTypeNameTestImpl(nativeType, expectedManagedType); - - [Test] - public Task GuidMacroTest() => GuidMacroTestImpl(); - - [TestCase("0", "int", "0")] - [TestCase("0U", "uint", "0U")] - [TestCase("0LL", "long", "0L")] - [TestCase("0ULL", "ulong", "0UL")] - [TestCase("0LLU", "ulong", "0UL")] - [TestCase("0.0", "double", "0.0")] - [TestCase("0.f", "float", "0.0f")] - public Task MacroTest(string nativeValue, string expectedManagedType, string expectedManagedValue) => MacroTestImpl(nativeValue, expectedManagedType, expectedManagedValue); - - [Test] - public Task MultilineMacroTest() => MultilineMacroTestImpl(); - - [TestCase("double")] - [TestCase("short")] - [TestCase("int")] - [TestCase("float")] - public Task NoInitializerTest(string nativeType) => NoInitializerTestImpl(nativeType); - - [Test] - public Task Utf8StringLiteralMacroTest() => Utf8StringLiteralMacroTestImpl(); - - [Test] - public Task Utf16StringLiteralMacroTest() => Utf16StringLiteralMacroTestImpl(); - - [Test] - public Task WideStringLiteralConstTest() => WideStringLiteralConstTestImpl(); - - [Test] - public Task StringLiteralConstTest() => StringLiteralConstTestImpl(); - - [Test] - public Task WideStringLiteralStaticConstTest() => WideStringLiteralStaticConstTestImpl(); - - [Test] - public Task StringLiteralStaticConstTest() => StringLiteralStaticConstTestImpl(); - - [Test] - public Task UncheckedConversionMacroTest() => UncheckedConversionMacroTestImpl(); - - [Test] - public Task UncheckedFunctionLikeCastMacroTest() => UncheckedFunctionLikeCastMacroTestImpl(); - - [Test] - public Task UncheckedConversionMacroTest2() => UncheckedConversionMacroTest2Impl(); - - [Test] - public Task UncheckedPointerMacroTest() => UncheckedPointerMacroTestImpl(); - - [Test] - public Task UncheckedReinterpretCastMacroTest() => UncheckedReinterpretCastMacroTestImpl(); - - [Test] - public Task MultidimensionlArrayTest() => MultidimensionlArrayTestImpl(); - - [Test] - public Task ConditionalDefineConstTest() => ConditionalDefineConstTestImpl(); - - [Test] - public Task UndefinedFunctionLikeMacroTest() => UndefinedFunctionLikeMacroTestImpl(); - - protected abstract Task BasicTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType); - - protected abstract Task GuidMacroTestImpl(); - - protected abstract Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue); - - protected abstract Task MultilineMacroTestImpl(); - - protected abstract Task NoInitializerTestImpl(string nativeType); - - protected abstract Task Utf8StringLiteralMacroTestImpl(); - - protected abstract Task Utf16StringLiteralMacroTestImpl(); - - protected abstract Task WideStringLiteralConstTestImpl(); - - protected abstract Task StringLiteralConstTestImpl(); - - protected abstract Task WideStringLiteralStaticConstTestImpl(); - - protected abstract Task StringLiteralStaticConstTestImpl(); - - protected abstract Task UncheckedConversionMacroTestImpl(); - - protected abstract Task UncheckedFunctionLikeCastMacroTestImpl(); - - protected abstract Task UncheckedConversionMacroTest2Impl(); - - protected abstract Task UncheckedPointerMacroTestImpl(); - - protected abstract Task UncheckedReinterpretCastMacroTestImpl(); - - protected abstract Task MultidimensionlArrayTestImpl(); - - protected abstract Task ConditionalDefineConstTestImpl(); - - protected abstract Task UndefinedFunctionLikeMacroTestImpl(); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineTest.cs index 687e6e87..20be8e6b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/BaselineTest.cs @@ -33,7 +33,7 @@ protected static IEnumerable Variants() var data = new TestFixtureData(variant); _ = data.SetArgDisplayNames(variant.ToString()); - if (!variant.MatchesHost) + if (!variant.MatchesHost && !BaselineHarness.RunAllVariants) { _ = data.Ignore($"{variant.Os} variant only runs on matching hosts"); } @@ -50,7 +50,8 @@ protected Task ValidateAsync(string method, string inputContents, string? discri private async Task ValidateCoreAsync(string caseName, string inputContents, PInvokeGeneratorConfigurationOptions additionalConfigOptions, string[]? excludedNames, IReadOnlyDictionary? remappedNames, IReadOnlyDictionary? withAccessSpecifiers, IReadOnlyDictionary>? withAttributes, IReadOnlyDictionary? withCallConvs, IReadOnlyDictionary? withClasses, IReadOnlyDictionary? withLibraryPaths, IReadOnlyDictionary? withNamespaces, string[]? withSetLastErrors, IReadOnlyDictionary? withTransparentStructs, IReadOnlyDictionary? withTypes, IReadOnlyDictionary>? withUsings, IReadOnlyDictionary? withPackings, IEnumerable? expectedDiagnostics, string libraryPath, string[]? commandLineArgs, string language, string languageStandard, IReadOnlyDictionary? remappedTypeNames, IReadOnlyDictionary? remappedFieldNames) { - var actual = await GenerateBindingsAsync(inputContents, _variant.Mode, _variant.ConfigOptions | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, withPackings, expectedDiagnostics, libraryPath, commandLineArgs, language, languageStandard, remappedTypeNames, remappedFieldNames).ConfigureAwait(false); + var effectiveCommandLineArgs = BaselineHarness.WithUnixTarget(commandLineArgs, DefaultCppClangCommandLineArgs, _variant.Os); + var actual = await GenerateBindingsAsync(inputContents, _variant.Mode, _variant.ConfigOptions | additionalConfigOptions, excludedNames, remappedNames, withAccessSpecifiers, withAttributes, withCallConvs, withClasses, withLibraryPaths, withNamespaces, withSetLastErrors, withTransparentStructs, withTypes, withUsings, withPackings, expectedDiagnostics, libraryPath, effectiveCommandLineArgs, language, languageStandard, remappedTypeNames, remappedFieldNames).ConfigureAwait(false); await BaselineAssertions.AssertOrUpdateAsync(Area, caseName, _variant, actual).ConfigureAwait(false); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorTest.CSharp.cs new file mode 100644 index 00000000..2f18e222 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorTest.CSharp.cs @@ -0,0 +1,12 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int _value; + + public MyStruct(int value) + { + _value = value; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorTest.Xml.xml new file mode 100644 index 00000000..b5995343 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorTest.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + + void + + int + + _value = value; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorWithInitializeTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorWithInitializeTest.CSharp.cs new file mode 100644 index 00000000..f4ca52c5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorWithInitializeTest.CSharp.cs @@ -0,0 +1,28 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int _x; + + public int _y; + + public int _z; + + public MyStruct(int x) + { + _x = x; + } + + public MyStruct(int x, int y) + { + _x = x; + _y = y; + } + + public MyStruct(int x, int y, int z) + { + _x = x; + _y = y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorWithInitializeTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorWithInitializeTest.Xml.xml new file mode 100644 index 00000000..8222ac99 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConstructorWithInitializeTest.Xml.xml @@ -0,0 +1,61 @@ + + + + + + int + + + int + + + int + + + void + + int + + + x + + + + + void + + int + + + int + + + x + + + y + + + + + void + + int + + + int + + + int + + + x + + + y + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConversionTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConversionTest.CSharp.cs new file mode 100644 index 00000000..4ccf2900 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConversionTest.CSharp.cs @@ -0,0 +1,33 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public int value; + + public int* pointer; + + public int** pointer2; + + public int*** pointer3; + + public int ToInt32() + { + return value; + } + + public int* ToInt32Pointer() + { + return pointer; + } + + public int** ToInt32PointerPointer() + { + return pointer2; + } + + public int*** ToInt32PointerPointerPointer() + { + return pointer3; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConversionTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConversionTest.Xml.xml new file mode 100644 index 00000000..6d373d33 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ConversionTest.Xml.xml @@ -0,0 +1,35 @@ + + + + + + int + + + int* + + + int** + + + int*** + + + int + return value; + + + int* + return pointer; + + + int** + return pointer2; + + + int*** + return pointer3; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..c44dcce0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,11 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [NativeTypeName("struct MyStruct : MyTemplate")] + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.ThisCall, EntryPoint = "_ZN10MyTemplateIiE6DoWorkEPi", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..11635723 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Compatible.Windows.cs @@ -0,0 +1,11 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [NativeTypeName("struct MyStruct : MyTemplate")] + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..c44dcce0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Default.Unix.cs @@ -0,0 +1,11 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [NativeTypeName("struct MyStruct : MyTemplate")] + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.ThisCall, EntryPoint = "_ZN10MyTemplateIiE6DoWorkEPi", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Default.Windows.cs new file mode 100644 index 00000000..11635723 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Default.Windows.cs @@ -0,0 +1,11 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [NativeTypeName("struct MyStruct : MyTemplate")] + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..c44dcce0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Latest.Unix.cs @@ -0,0 +1,11 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [NativeTypeName("struct MyStruct : MyTemplate")] + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.ThisCall, EntryPoint = "_ZN10MyTemplateIiE6DoWorkEPi", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..11635723 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Latest.Windows.cs @@ -0,0 +1,11 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [NativeTypeName("struct MyStruct : MyTemplate")] + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..c44dcce0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Preview.Unix.cs @@ -0,0 +1,11 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [NativeTypeName("struct MyStruct : MyTemplate")] + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.ThisCall, EntryPoint = "_ZN10MyTemplateIiE6DoWorkEPi", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..11635723 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.CSharp.Preview.Windows.cs @@ -0,0 +1,11 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [NativeTypeName("struct MyStruct : MyTemplate")] + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z", ExactSpelling = true)] + public static extern int* DoWork(MyStruct* pThis, int* value = null); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..b66bee16 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Compatible.Unix.xml @@ -0,0 +1,19 @@ + + + + + + int* + + MyStruct* + + + int* + + null + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Compatible.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Compatible.Windows.xml new file mode 100644 index 00000000..412e9c2c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Compatible.Windows.xml @@ -0,0 +1,19 @@ + + + + + + int* + + MyStruct* + + + int* + + null + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..b66bee16 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Default.Unix.xml @@ -0,0 +1,19 @@ + + + + + + int* + + MyStruct* + + + int* + + null + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Default.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Default.Windows.xml new file mode 100644 index 00000000..412e9c2c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Default.Windows.xml @@ -0,0 +1,19 @@ + + + + + + int* + + MyStruct* + + + int* + + null + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..b66bee16 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Latest.Unix.xml @@ -0,0 +1,19 @@ + + + + + + int* + + MyStruct* + + + int* + + null + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Latest.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Latest.Windows.xml new file mode 100644 index 00000000..412e9c2c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Latest.Windows.xml @@ -0,0 +1,19 @@ + + + + + + int* + + MyStruct* + + + int* + + null + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..b66bee16 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Preview.Unix.xml @@ -0,0 +1,19 @@ + + + + + + int* + + MyStruct* + + + int* + + null + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Preview.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Preview.Windows.xml new file mode 100644 index 00000000..412e9c2c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DefaultParameterInheritedFromTemplateTest.Xml.Preview.Windows.xml @@ -0,0 +1,19 @@ + + + + + + int* + + MyStruct* + + + int* + + null + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DestructorTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DestructorTest.CSharp.cs new file mode 100644 index 00000000..c7b76763 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DestructorTest.CSharp.cs @@ -0,0 +1,9 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public void Dispose() + { + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DestructorTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DestructorTest.Xml.xml new file mode 100644 index 00000000..9223ae48 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/DestructorTest.Xml.xml @@ -0,0 +1,11 @@ + + + + + + void + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..d1204429 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.ThisCall, EntryPoint = "_ZN8MyStruct12MyVoidMethodEv", ExactSpelling = true)] + public static extern void MyVoidMethod(MyStruct* pThis); + + public int MyInt32Method() + { + return 0; + } + + public void* MyVoidStarMethod() + { + return null; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..d1204429 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Default.Unix.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.ThisCall, EntryPoint = "_ZN8MyStruct12MyVoidMethodEv", ExactSpelling = true)] + public static extern void MyVoidMethod(MyStruct* pThis); + + public int MyInt32Method() + { + return 0; + } + + public void* MyVoidStarMethod() + { + return null; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..d1204429 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Latest.Unix.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.ThisCall, EntryPoint = "_ZN8MyStruct12MyVoidMethodEv", ExactSpelling = true)] + public static extern void MyVoidMethod(MyStruct* pThis); + + public int MyInt32Method() + { + return 0; + } + + public void* MyVoidStarMethod() + { + return null; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..d1204429 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.Preview.Unix.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.ThisCall, EntryPoint = "_ZN8MyStruct12MyVoidMethodEv", ExactSpelling = true)] + public static extern void MyVoidMethod(MyStruct* pThis); + + public int MyInt32Method() + { + return 0; + } + + public void* MyVoidStarMethod() + { + return null; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.cs new file mode 100644 index 00000000..da8c52c6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.ThisCall, EntryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ", ExactSpelling = true)] + public static extern void MyVoidMethod(MyStruct* pThis); + + public int MyInt32Method() + { + return 0; + } + + public void* MyVoidStarMethod() + { + return null; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..c68a9c76 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Compatible.Unix.xml @@ -0,0 +1,21 @@ + + + + + + void + + MyStruct* + + + + int + return 0; + + + void* + return null; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..c68a9c76 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Default.Unix.xml @@ -0,0 +1,21 @@ + + + + + + void + + MyStruct* + + + + int + return 0; + + + void* + return null; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..c68a9c76 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Latest.Unix.xml @@ -0,0 +1,21 @@ + + + + + + void + + MyStruct* + + + + int + return 0; + + + void* + return null; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..c68a9c76 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.Preview.Unix.xml @@ -0,0 +1,21 @@ + + + + + + void + + MyStruct* + + + + int + return 0; + + + void* + return null; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.xml new file mode 100644 index 00000000..f874b78c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/InstanceTest.Xml.xml @@ -0,0 +1,21 @@ + + + + + + void + + MyStruct* + + + + int + return 0; + + + void* + return null; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MacrosExpansionTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MacrosExpansionTest.CSharp.cs new file mode 100644 index 00000000..23d2e43e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MacrosExpansionTest.CSharp.cs @@ -0,0 +1,19 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct context_t + { + [NativeTypeName("unsigned char *")] + public byte* buf; + + public int size; + } + + public static unsafe partial class Methods + { + public static int buf_close(void* pContext) + { + ((context_t*)(pContext))->buf = null; + return 0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MacrosExpansionTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MacrosExpansionTest.Xml.xml new file mode 100644 index 00000000..9bc0af1b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MacrosExpansionTest.Xml.xml @@ -0,0 +1,23 @@ + + + + + + byte* + + + int + + + + + int + + void* + + ((context_t*)(pContext))->buf = null; + return 0; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberCallTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberCallTest.CSharp.cs new file mode 100644 index 00000000..f8d3c170 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberCallTest.CSharp.cs @@ -0,0 +1,35 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + + public int MyFunction1() + { + return value; + } + + public int MyFunction2() + { + return MyFunction1(); + } + + public int MyFunction3() + { + return this.MyFunction1(); + } + } + + public static unsafe partial class Methods + { + public static int MyFunctionA(MyStruct x) + { + return x.MyFunction1(); + } + + public static int MyFunctionB(MyStruct* x) + { + return x->MyFunction2(); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberCallTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberCallTest.Xml.xml new file mode 100644 index 00000000..84cbc6a0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberCallTest.Xml.xml @@ -0,0 +1,38 @@ + + + + + + int + + + int + return value; + + + int + return MyFunction1(); + + + int + return this.MyFunction1(); + + + + + int + + MyStruct + + return x.MyFunction1(); + + + int + + MyStruct* + + return x->MyFunction2(); + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberTest.CSharp.cs new file mode 100644 index 00000000..74115c12 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberTest.CSharp.cs @@ -0,0 +1,12 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + + public int MyFunction() + { + return value; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberTest.Xml.xml new file mode 100644 index 00000000..c0c48e91 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/MemberTest.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int + + + int + return value; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordTest.CSharp.cs new file mode 100644 index 00000000..790dfed4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordTest.CSharp.cs @@ -0,0 +1,75 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int Equals() + { + return 0; + } + + public int Equals(int obj) + { + return 0; + } + + public int Dispose() + { + return 0; + } + + public int Dispose(int obj) + { + return 0; + } + + public new int GetHashCode() + { + return 0; + } + + public int GetHashCode(int obj) + { + return 0; + } + + public new int GetType() + { + return 0; + } + + public int GetType(int obj) + { + return 0; + } + + public new int MemberwiseClone() + { + return 0; + } + + public int MemberwiseClone(int obj) + { + return 0; + } + + public int ReferenceEquals() + { + return 0; + } + + public int ReferenceEquals(int obj) + { + return 0; + } + + public new int ToString() + { + return 0; + } + + public int ToString(int obj) + { + return 0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordTest.Xml.xml new file mode 100644 index 00000000..bdfd1a3b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordTest.Xml.xml @@ -0,0 +1,84 @@ + + + + + + int + return 0; + + + int + + int + + return 0; + + + int + return 0; + + + int + + int + + return 0; + + + int + return 0; + + + int + + int + + return 0; + + + int + return 0; + + + int + + int + + return 0; + + + int + return 0; + + + int + + int + + return 0; + + + int + return 0; + + + int + + int + + return 0; + + + int + return 0; + + + int + + int + + return 0; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..c6947a8d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,43 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType(MyStruct* pThis, int obj); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType1(MyStruct* pThis); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType2(MyStruct* pThis, int objA, int objB); + + public int GetType(int obj) + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType>((IntPtr)(lpVtbl[0]))(pThis, obj); + } + } + + public new int GetType() + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType1>((IntPtr)(lpVtbl[1]))(pThis); + } + } + + public int GetType(int objA, int objB) + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType2>((IntPtr)(lpVtbl[2]))(pThis, objA, objB); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..6333da6b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Compatible.Windows.cs @@ -0,0 +1,43 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType(MyStruct* pThis, int objA, int objB); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType1(MyStruct* pThis); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType2(MyStruct* pThis, int obj); + + public int GetType(int objA, int objB) + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType>((IntPtr)(lpVtbl[0]))(pThis, objA, objB); + } + } + + public new int GetType() + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType1>((IntPtr)(lpVtbl[1]))(pThis); + } + } + + public int GetType(int obj) + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType2>((IntPtr)(lpVtbl[2]))(pThis, obj); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..43e838c8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Default.Unix.cs @@ -0,0 +1,24 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + public int GetType(int obj) + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public new int GetType() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int objA, int objB) + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Default.Windows.cs new file mode 100644 index 00000000..c6a33d7d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Default.Windows.cs @@ -0,0 +1,24 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + public int GetType(int objA, int objB) + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public new int GetType() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int obj) + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..43e838c8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Latest.Unix.cs @@ -0,0 +1,24 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + public int GetType(int obj) + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public new int GetType() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int objA, int objB) + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..c6a33d7d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Latest.Windows.cs @@ -0,0 +1,24 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + public int GetType(int objA, int objB) + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public new int GetType() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int obj) + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..43e838c8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Preview.Unix.cs @@ -0,0 +1,24 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + public int GetType(int obj) + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public new int GetType() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int objA, int objB) + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..c6a33d7d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.CSharp.Preview.Windows.cs @@ -0,0 +1,24 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + public int GetType(int objA, int objB) + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public new int GetType() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int obj) + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..7a0438cd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Compatible.Unix.xml @@ -0,0 +1,73 @@ + + + + + + void** + + + int + + MyStruct* + + + int + + + + int + + MyStruct* + + + + int + + MyStruct* + + + int + + + int + + + + int + + int + + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType>((IntPtr)(lpVtbl[0]))(pThis, obj); + } + + + + int + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType1>((IntPtr)(lpVtbl[1]))(pThis); + } + + + + int + + int + + + int + + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType2>((IntPtr)(lpVtbl[2]))(pThis, objA, objB); + } + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Compatible.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Compatible.Windows.xml new file mode 100644 index 00000000..f5e1b276 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Compatible.Windows.xml @@ -0,0 +1,73 @@ + + + + + + void** + + + int + + MyStruct* + + + int + + + int + + + + int + + MyStruct* + + + + int + + MyStruct* + + + int + + + + int + + int + + + int + + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType>((IntPtr)(lpVtbl[0]))(pThis, objA, objB); + } + + + + int + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType1>((IntPtr)(lpVtbl[1]))(pThis); + } + + + + int + + int + + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType2>((IntPtr)(lpVtbl[2]))(pThis, obj); + } + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..00072249 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Default.Unix.xml @@ -0,0 +1,37 @@ + + + + + + void** + + + int + + int + + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + int + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + int + + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Default.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Default.Windows.xml new file mode 100644 index 00000000..b7ebefa1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Default.Windows.xml @@ -0,0 +1,37 @@ + + + + + + void** + + + int + + int + + + int + + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int, int>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + int + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..00072249 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Latest.Unix.xml @@ -0,0 +1,37 @@ + + + + + + void** + + + int + + int + + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + int + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + int + + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Latest.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Latest.Windows.xml new file mode 100644 index 00000000..b7ebefa1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Latest.Windows.xml @@ -0,0 +1,37 @@ + + + + + + void** + + + int + + int + + + int + + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int, int>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + int + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..00072249 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Preview.Unix.xml @@ -0,0 +1,37 @@ + + + + + + void** + + + int + + int + + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + int + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + int + + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Preview.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Preview.Windows.xml new file mode 100644 index 00000000..b7ebefa1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualTest.Xml.Preview.Windows.xml @@ -0,0 +1,37 @@ + + + + + + void** + + + int + + int + + + int + + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int, int>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + int + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..ad6830b1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,64 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct : MyStruct.Interface + { + public Vtbl* lpVtbl; + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType(MyStruct* pThis, int obj); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType1(MyStruct* pThis); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType2(MyStruct* pThis, int objA, int objB); + + public int GetType(int obj) + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, obj); + } + } + + public new int GetType() + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); + } + } + + public int GetType(int objA, int objB) + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, objA, objB); + } + } + + public interface Interface + { + int GetType(int obj); + + int GetType(); + + int GetType(int objA, int objB); + } + + public partial struct Vtbl + { + [NativeTypeName("int (int)")] + public new IntPtr GetType; + + [NativeTypeName("int ()")] + public IntPtr GetType1; + + [NativeTypeName("int (int, int)")] + public IntPtr GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..ba92ce4b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Compatible.Windows.cs @@ -0,0 +1,64 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct : MyStruct.Interface + { + public Vtbl* lpVtbl; + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType(MyStruct* pThis, int objA, int objB); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType1(MyStruct* pThis); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType2(MyStruct* pThis, int obj); + + public int GetType(int objA, int objB) + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, objA, objB); + } + } + + public new int GetType() + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); + } + } + + public int GetType(int obj) + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, obj); + } + } + + public interface Interface + { + int GetType(int objA, int objB); + + int GetType(); + + int GetType(int obj); + } + + public partial struct Vtbl + { + [NativeTypeName("int (int, int)")] + public new IntPtr GetType; + + [NativeTypeName("int ()")] + public IntPtr GetType1; + + [NativeTypeName("int (int)")] + public IntPtr GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..fda26b8b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Default.Unix.cs @@ -0,0 +1,46 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct : MyStruct.Interface + { + public Vtbl* lpVtbl; + + public int GetType(int obj) + { + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public new int GetType() + { + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int objA, int objB) + { + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public interface Interface + { + int GetType(int obj); + + int GetType(); + + int GetType(int objA, int objB); + } + + public partial struct Vtbl + where TSelf : unmanaged, Interface + { + [NativeTypeName("int (int)")] + public new delegate* unmanaged[Thiscall] GetType; + + [NativeTypeName("int ()")] + public delegate* unmanaged[Thiscall] GetType1; + + [NativeTypeName("int (int, int)")] + public delegate* unmanaged[Thiscall] GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Default.Windows.cs new file mode 100644 index 00000000..0e94284a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Default.Windows.cs @@ -0,0 +1,46 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct : MyStruct.Interface + { + public Vtbl* lpVtbl; + + public int GetType(int objA, int objB) + { + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public new int GetType() + { + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int obj) + { + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public interface Interface + { + int GetType(int objA, int objB); + + int GetType(); + + int GetType(int obj); + } + + public partial struct Vtbl + where TSelf : unmanaged, Interface + { + [NativeTypeName("int (int, int)")] + public new delegate* unmanaged[Thiscall] GetType; + + [NativeTypeName("int ()")] + public delegate* unmanaged[Thiscall] GetType1; + + [NativeTypeName("int (int)")] + public delegate* unmanaged[Thiscall] GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..fda26b8b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Latest.Unix.cs @@ -0,0 +1,46 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct : MyStruct.Interface + { + public Vtbl* lpVtbl; + + public int GetType(int obj) + { + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public new int GetType() + { + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int objA, int objB) + { + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public interface Interface + { + int GetType(int obj); + + int GetType(); + + int GetType(int objA, int objB); + } + + public partial struct Vtbl + where TSelf : unmanaged, Interface + { + [NativeTypeName("int (int)")] + public new delegate* unmanaged[Thiscall] GetType; + + [NativeTypeName("int ()")] + public delegate* unmanaged[Thiscall] GetType1; + + [NativeTypeName("int (int, int)")] + public delegate* unmanaged[Thiscall] GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..0e94284a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Latest.Windows.cs @@ -0,0 +1,46 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct : MyStruct.Interface + { + public Vtbl* lpVtbl; + + public int GetType(int objA, int objB) + { + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public new int GetType() + { + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int obj) + { + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public interface Interface + { + int GetType(int objA, int objB); + + int GetType(); + + int GetType(int obj); + } + + public partial struct Vtbl + where TSelf : unmanaged, Interface + { + [NativeTypeName("int (int, int)")] + public new delegate* unmanaged[Thiscall] GetType; + + [NativeTypeName("int ()")] + public delegate* unmanaged[Thiscall] GetType1; + + [NativeTypeName("int (int)")] + public delegate* unmanaged[Thiscall] GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..fda26b8b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Preview.Unix.cs @@ -0,0 +1,46 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct : MyStruct.Interface + { + public Vtbl* lpVtbl; + + public int GetType(int obj) + { + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public new int GetType() + { + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int objA, int objB) + { + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public interface Interface + { + int GetType(int obj); + + int GetType(); + + int GetType(int objA, int objB); + } + + public partial struct Vtbl + where TSelf : unmanaged, Interface + { + [NativeTypeName("int (int)")] + public new delegate* unmanaged[Thiscall] GetType; + + [NativeTypeName("int ()")] + public delegate* unmanaged[Thiscall] GetType1; + + [NativeTypeName("int (int, int)")] + public delegate* unmanaged[Thiscall] GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..0e94284a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.CSharp.Preview.Windows.cs @@ -0,0 +1,46 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct : MyStruct.Interface + { + public Vtbl* lpVtbl; + + public int GetType(int objA, int objB) + { + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public new int GetType() + { + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int obj) + { + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public interface Interface + { + int GetType(int objA, int objB); + + int GetType(); + + int GetType(int obj); + } + + public partial struct Vtbl + where TSelf : unmanaged, Interface + { + [NativeTypeName("int (int, int)")] + public new delegate* unmanaged[Thiscall] GetType; + + [NativeTypeName("int ()")] + public delegate* unmanaged[Thiscall] GetType1; + + [NativeTypeName("int (int)")] + public delegate* unmanaged[Thiscall] GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..31299001 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Compatible.Unix.xml @@ -0,0 +1,104 @@ + + + + + + Vtbl* + + + int + + MyStruct* + + + int + + + + int + + MyStruct* + + + + int + + MyStruct* + + + int + + + int + + + + int + + int + + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, obj); + } + + + + int + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); + } + + + + int + + int + + + int + + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, objA, objB); + } + + + + + int + + int + + + + int + + + int + + int + + + int + + + + + + IntPtr + + + IntPtr + + + IntPtr + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Compatible.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Compatible.Windows.xml new file mode 100644 index 00000000..5525d021 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Compatible.Windows.xml @@ -0,0 +1,104 @@ + + + + + + Vtbl* + + + int + + MyStruct* + + + int + + + int + + + + int + + MyStruct* + + + + int + + MyStruct* + + + int + + + + int + + int + + + int + + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, objA, objB); + } + + + + int + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); + } + + + + int + + int + + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, obj); + } + + + + + int + + int + + + int + + + + int + + + int + + int + + + + + + IntPtr + + + IntPtr + + + IntPtr + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..b9518f46 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Default.Unix.xml @@ -0,0 +1,68 @@ + + + + + + Vtbl<MyStruct>* + + + int + + int + + + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + int + + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + int + + + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + + int + + int + + + + int + + + int + + int + + + int + + + + + + delegate* unmanaged[Thiscall]<TSelf*, int, int> + + + delegate* unmanaged[Thiscall]<TSelf*, int> + + + delegate* unmanaged[Thiscall]<TSelf*, int, int, int> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Default.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Default.Windows.xml new file mode 100644 index 00000000..273c686f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Default.Windows.xml @@ -0,0 +1,68 @@ + + + + + + Vtbl<MyStruct>* + + + int + + int + + + int + + + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + int + + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + + int + + int + + + int + + + + int + + + int + + int + + + + + + delegate* unmanaged[Thiscall]<TSelf*, int, int, int> + + + delegate* unmanaged[Thiscall]<TSelf*, int> + + + delegate* unmanaged[Thiscall]<TSelf*, int, int> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..b9518f46 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Latest.Unix.xml @@ -0,0 +1,68 @@ + + + + + + Vtbl<MyStruct>* + + + int + + int + + + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + int + + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + int + + + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + + int + + int + + + + int + + + int + + int + + + int + + + + + + delegate* unmanaged[Thiscall]<TSelf*, int, int> + + + delegate* unmanaged[Thiscall]<TSelf*, int> + + + delegate* unmanaged[Thiscall]<TSelf*, int, int, int> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Latest.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Latest.Windows.xml new file mode 100644 index 00000000..273c686f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Latest.Windows.xml @@ -0,0 +1,68 @@ + + + + + + Vtbl<MyStruct>* + + + int + + int + + + int + + + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + int + + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + + int + + int + + + int + + + + int + + + int + + int + + + + + + delegate* unmanaged[Thiscall]<TSelf*, int, int, int> + + + delegate* unmanaged[Thiscall]<TSelf*, int> + + + delegate* unmanaged[Thiscall]<TSelf*, int, int> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..b9518f46 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Preview.Unix.xml @@ -0,0 +1,68 @@ + + + + + + Vtbl<MyStruct>* + + + int + + int + + + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + int + + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + int + + + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + + int + + int + + + + int + + + int + + int + + + int + + + + + + delegate* unmanaged[Thiscall]<TSelf*, int, int> + + + delegate* unmanaged[Thiscall]<TSelf*, int> + + + delegate* unmanaged[Thiscall]<TSelf*, int, int, int> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Preview.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Preview.Windows.xml new file mode 100644 index 00000000..273c686f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest.Xml.Preview.Windows.xml @@ -0,0 +1,68 @@ + + + + + + Vtbl<MyStruct>* + + + int + + int + + + int + + + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + int + + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + + int + + int + + + int + + + + int + + + int + + int + + + + + + delegate* unmanaged[Thiscall]<TSelf*, int, int, int> + + + delegate* unmanaged[Thiscall]<TSelf*, int> + + + delegate* unmanaged[Thiscall]<TSelf*, int, int> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..ef063190 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,55 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public Vtbl* lpVtbl; + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType(MyStruct* pThis, int obj); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType1(MyStruct* pThis); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType2(MyStruct* pThis, int objA, int objB); + + public int GetType(int obj) + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, obj); + } + } + + public new int GetType() + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); + } + } + + public int GetType(int objA, int objB) + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, objA, objB); + } + } + + public partial struct Vtbl + { + [NativeTypeName("int (int)")] + public new IntPtr GetType; + + [NativeTypeName("int ()")] + public IntPtr GetType1; + + [NativeTypeName("int (int, int)")] + public IntPtr GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..b8150a37 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Compatible.Windows.cs @@ -0,0 +1,55 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public Vtbl* lpVtbl; + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType(MyStruct* pThis, int objA, int objB); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType1(MyStruct* pThis); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _GetType2(MyStruct* pThis, int obj); + + public int GetType(int objA, int objB) + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, objA, objB); + } + } + + public new int GetType() + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); + } + } + + public int GetType(int obj) + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, obj); + } + } + + public partial struct Vtbl + { + [NativeTypeName("int (int, int)")] + public new IntPtr GetType; + + [NativeTypeName("int ()")] + public IntPtr GetType1; + + [NativeTypeName("int (int)")] + public IntPtr GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..6f5663c8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Default.Unix.cs @@ -0,0 +1,36 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public Vtbl* lpVtbl; + + public int GetType(int obj) + { + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public new int GetType() + { + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int objA, int objB) + { + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public partial struct Vtbl + { + [NativeTypeName("int (int)")] + public new delegate* unmanaged[Thiscall] GetType; + + [NativeTypeName("int ()")] + public delegate* unmanaged[Thiscall] GetType1; + + [NativeTypeName("int (int, int)")] + public delegate* unmanaged[Thiscall] GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Default.Windows.cs new file mode 100644 index 00000000..15da4204 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Default.Windows.cs @@ -0,0 +1,36 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public Vtbl* lpVtbl; + + public int GetType(int objA, int objB) + { + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public new int GetType() + { + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int obj) + { + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public partial struct Vtbl + { + [NativeTypeName("int (int, int)")] + public new delegate* unmanaged[Thiscall] GetType; + + [NativeTypeName("int ()")] + public delegate* unmanaged[Thiscall] GetType1; + + [NativeTypeName("int (int)")] + public delegate* unmanaged[Thiscall] GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..6f5663c8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Latest.Unix.cs @@ -0,0 +1,36 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public Vtbl* lpVtbl; + + public int GetType(int obj) + { + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public new int GetType() + { + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int objA, int objB) + { + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public partial struct Vtbl + { + [NativeTypeName("int (int)")] + public new delegate* unmanaged[Thiscall] GetType; + + [NativeTypeName("int ()")] + public delegate* unmanaged[Thiscall] GetType1; + + [NativeTypeName("int (int, int)")] + public delegate* unmanaged[Thiscall] GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..15da4204 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Latest.Windows.cs @@ -0,0 +1,36 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public Vtbl* lpVtbl; + + public int GetType(int objA, int objB) + { + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public new int GetType() + { + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int obj) + { + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public partial struct Vtbl + { + [NativeTypeName("int (int, int)")] + public new delegate* unmanaged[Thiscall] GetType; + + [NativeTypeName("int ()")] + public delegate* unmanaged[Thiscall] GetType1; + + [NativeTypeName("int (int)")] + public delegate* unmanaged[Thiscall] GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..6f5663c8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Preview.Unix.cs @@ -0,0 +1,36 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public Vtbl* lpVtbl; + + public int GetType(int obj) + { + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public new int GetType() + { + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int objA, int objB) + { + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public partial struct Vtbl + { + [NativeTypeName("int (int)")] + public new delegate* unmanaged[Thiscall] GetType; + + [NativeTypeName("int ()")] + public delegate* unmanaged[Thiscall] GetType1; + + [NativeTypeName("int (int, int)")] + public delegate* unmanaged[Thiscall] GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..15da4204 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.CSharp.Preview.Windows.cs @@ -0,0 +1,36 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public Vtbl* lpVtbl; + + public int GetType(int objA, int objB) + { + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + } + + public new int GetType() + { + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int GetType(int obj) + { + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); + } + + public partial struct Vtbl + { + [NativeTypeName("int (int, int)")] + public new delegate* unmanaged[Thiscall] GetType; + + [NativeTypeName("int ()")] + public delegate* unmanaged[Thiscall] GetType1; + + [NativeTypeName("int (int)")] + public delegate* unmanaged[Thiscall] GetType2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..399f4fe7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Compatible.Unix.xml @@ -0,0 +1,84 @@ + + + + + + Vtbl* + + + int + + MyStruct* + + + int + + + + int + + MyStruct* + + + + int + + MyStruct* + + + int + + + int + + + + int + + int + + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, obj); + } + + + + int + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); + } + + + + int + + int + + + int + + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, objA, objB); + } + + + + + IntPtr + + + IntPtr + + + IntPtr + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Compatible.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Compatible.Windows.xml new file mode 100644 index 00000000..71b122fb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Compatible.Windows.xml @@ -0,0 +1,84 @@ + + + + + + Vtbl* + + + int + + MyStruct* + + + int + + + int + + + + int + + MyStruct* + + + + int + + MyStruct* + + + int + + + + int + + int + + + int + + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, objA, objB); + } + + + + int + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); + } + + + + int + + int + + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, obj); + } + + + + + IntPtr + + + IntPtr + + + IntPtr + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..bcdcff1b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Default.Unix.xml @@ -0,0 +1,48 @@ + + + + + + Vtbl* + + + int + + int + + + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + int + + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + int + + + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + + delegate* unmanaged[Thiscall]<MyStruct*, int, int> + + + delegate* unmanaged[Thiscall]<MyStruct*, int> + + + delegate* unmanaged[Thiscall]<MyStruct*, int, int, int> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Default.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Default.Windows.xml new file mode 100644 index 00000000..3ff74f5e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Default.Windows.xml @@ -0,0 +1,48 @@ + + + + + + Vtbl* + + + int + + int + + + int + + + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + int + + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + + delegate* unmanaged[Thiscall]<MyStruct*, int, int, int> + + + delegate* unmanaged[Thiscall]<MyStruct*, int> + + + delegate* unmanaged[Thiscall]<MyStruct*, int, int> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..bcdcff1b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Latest.Unix.xml @@ -0,0 +1,48 @@ + + + + + + Vtbl* + + + int + + int + + + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + int + + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + int + + + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + + delegate* unmanaged[Thiscall]<MyStruct*, int, int> + + + delegate* unmanaged[Thiscall]<MyStruct*, int> + + + delegate* unmanaged[Thiscall]<MyStruct*, int, int, int> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Latest.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Latest.Windows.xml new file mode 100644 index 00000000..3ff74f5e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Latest.Windows.xml @@ -0,0 +1,48 @@ + + + + + + Vtbl* + + + int + + int + + + int + + + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + int + + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + + delegate* unmanaged[Thiscall]<MyStruct*, int, int, int> + + + delegate* unmanaged[Thiscall]<MyStruct*, int> + + + delegate* unmanaged[Thiscall]<MyStruct*, int, int> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..bcdcff1b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Preview.Unix.xml @@ -0,0 +1,48 @@ + + + + + + Vtbl* + + + int + + int + + + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + int + + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + int + + + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + + delegate* unmanaged[Thiscall]<MyStruct*, int, int> + + + delegate* unmanaged[Thiscall]<MyStruct*, int> + + + delegate* unmanaged[Thiscall]<MyStruct*, int, int, int> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Preview.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Preview.Windows.xml new file mode 100644 index 00000000..3ff74f5e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/NewKeywordVirtualWithExplicitVtblTest.Xml.Preview.Windows.xml @@ -0,0 +1,48 @@ + + + + + + Vtbl* + + + int + + int + + + int + + + return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); + + + + int + + return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + int + + + return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); + + + + + delegate* unmanaged[Thiscall]<MyStruct*, int, int, int> + + + delegate* unmanaged[Thiscall]<MyStruct*, int> + + + delegate* unmanaged[Thiscall]<MyStruct*, int, int> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorCallTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorCallTest.CSharp.cs new file mode 100644 index 00000000..f2da1d51 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorCallTest.CSharp.cs @@ -0,0 +1,35 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + + public MyStruct(int value) + { + this.value = value; + } + + public MyStruct Add(MyStruct rhs) + { + return new MyStruct(value + rhs.value); + } + } + + public static partial class Methods + { + public static MyStruct MyFunction1(MyStruct lhs, MyStruct rhs) + { + return lhs.Add(rhs); + } + + public static MyStruct Subtract(MyStruct lhs, MyStruct rhs) + { + return new MyStruct(lhs.value - rhs.value); + } + + public static MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) + { + return Subtract(lhs, rhs); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorCallTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorCallTest.Xml.xml new file mode 100644 index 00000000..f41d5272 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorCallTest.Xml.xml @@ -0,0 +1,59 @@ + + + + + + int + + + void + + int + + + value + + + + + MyStruct + + MyStruct + + return new MyStruct(value + rhs.value); + + + + + MyStruct + + MyStruct + + + MyStruct + + return lhs.Add(rhs); + + + MyStruct + + MyStruct + + + MyStruct + + return new MyStruct(lhs.value - rhs.value); + + + MyStruct + + MyStruct + + + MyStruct + + return Subtract(lhs, rhs); + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorTest.CSharp.cs new file mode 100644 index 00000000..dcdc3cbd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorTest.CSharp.cs @@ -0,0 +1,25 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + + public MyStruct(int value) + { + this.value = value; + } + + public MyStruct Add(MyStruct rhs) + { + return new MyStruct(value + rhs.value); + } + } + + public static partial class Methods + { + public static MyStruct Subtract(MyStruct lhs, MyStruct rhs) + { + return new MyStruct(lhs.value - rhs.value); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorTest.Xml.xml new file mode 100644 index 00000000..1f20f49b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/OperatorTest.Xml.xml @@ -0,0 +1,39 @@ + + + + + + int + + + void + + int + + + value + + + + + MyStruct + + MyStruct + + return new MyStruct(value + rhs.value); + + + + + MyStruct + + MyStruct + + + MyStruct + + return new MyStruct(lhs.value - rhs.value); + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..153b9444 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, EntryPoint = "_ZN8MyStruct12MyVoidMethodEv", ExactSpelling = true)] + public static extern void MyVoidMethod(); + + public static int MyInt32Method() + { + return 0; + } + + public static void* MyVoidStarMethod() + { + return null; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..153b9444 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Default.Unix.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, EntryPoint = "_ZN8MyStruct12MyVoidMethodEv", ExactSpelling = true)] + public static extern void MyVoidMethod(); + + public static int MyInt32Method() + { + return 0; + } + + public static void* MyVoidStarMethod() + { + return null; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..153b9444 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Latest.Unix.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, EntryPoint = "_ZN8MyStruct12MyVoidMethodEv", ExactSpelling = true)] + public static extern void MyVoidMethod(); + + public static int MyInt32Method() + { + return 0; + } + + public static void* MyVoidStarMethod() + { + return null; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..153b9444 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.Preview.Unix.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, EntryPoint = "_ZN8MyStruct12MyVoidMethodEv", ExactSpelling = true)] + public static extern void MyVoidMethod(); + + public static int MyInt32Method() + { + return 0; + } + + public static void* MyVoidStarMethod() + { + return null; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.cs new file mode 100644 index 00000000..81ad1ea6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, EntryPoint = "?MyVoidMethod@MyStruct@@SAXXZ", ExactSpelling = true)] + public static extern void MyVoidMethod(); + + public static int MyInt32Method() + { + return 0; + } + + public static void* MyVoidStarMethod() + { + return null; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..5bd1174c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Compatible.Unix.xml @@ -0,0 +1,18 @@ + + + + + + void + + + int + return 0; + + + void* + return null; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..5bd1174c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Default.Unix.xml @@ -0,0 +1,18 @@ + + + + + + void + + + int + return 0; + + + void* + return null; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..5bd1174c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Latest.Unix.xml @@ -0,0 +1,18 @@ + + + + + + void + + + int + return 0; + + + void* + return null; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..5bd1174c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.Preview.Unix.xml @@ -0,0 +1,18 @@ + + + + + + void + + + int + return 0; + + + void* + return null; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.xml new file mode 100644 index 00000000..699c4410 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/StaticTest.Xml.xml @@ -0,0 +1,18 @@ + + + + + + void + + + int + return 0; + + + void* + return null; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ThisTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ThisTest.CSharp.cs new file mode 100644 index 00000000..4fc497af --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ThisTest.CSharp.cs @@ -0,0 +1,12 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + + public int MyFunction() + { + return this.value; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ThisTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ThisTest.Xml.xml new file mode 100644 index 00000000..6cf6eb53 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/ThisTest.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int + + + int + return this.value; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/UnsafeDoesNotImpactDllImportTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/UnsafeDoesNotImpactDllImportTest.CSharp.cs new file mode 100644 index 00000000..109086f5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/UnsafeDoesNotImpactDllImportTest.CSharp.cs @@ -0,0 +1,18 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void* MyVoidStarMethod() + { + return null; + } + } + + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/UnsafeDoesNotImpactDllImportTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/UnsafeDoesNotImpactDllImportTest.Xml.xml new file mode 100644 index 00000000..339db33f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/UnsafeDoesNotImpactDllImportTest.Xml.xml @@ -0,0 +1,16 @@ + + + + + + void* + return null; + + + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Compatible.cs new file mode 100644 index 00000000..bbcc5a58 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Compatible.cs @@ -0,0 +1,56 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate void _MyVoidMethod(MyStruct* pThis); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + [return: NativeTypeName("signed char")] + public delegate sbyte _MyInt8Method(MyStruct* pThis); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _MyInt32Method(MyStruct* pThis); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate void* _MyVoidStarMethod(MyStruct* pThis); + + public void MyVoidMethod() + { + fixed (MyStruct* pThis = &this) + { + Marshal.GetDelegateForFunctionPointer<_MyVoidMethod>((IntPtr)(lpVtbl[0]))(pThis); + } + } + + [return: NativeTypeName("signed char")] + public sbyte MyInt8Method() + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_MyInt8Method>((IntPtr)(lpVtbl[1]))(pThis); + } + } + + public int MyInt32Method() + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_MyInt32Method>((IntPtr)(lpVtbl[2]))(pThis); + } + } + + public void* MyVoidStarMethod() + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_MyVoidStarMethod>((IntPtr)(lpVtbl[3]))(pThis); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Default.cs new file mode 100644 index 00000000..02a3d2ff --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Default.cs @@ -0,0 +1,30 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + public void MyVoidMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + [return: NativeTypeName("signed char")] + public sbyte MyInt8Method() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int MyInt32Method() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public void* MyVoidStarMethod() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Latest.cs new file mode 100644 index 00000000..02a3d2ff --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Latest.cs @@ -0,0 +1,30 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + public void MyVoidMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + [return: NativeTypeName("signed char")] + public sbyte MyInt8Method() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int MyInt32Method() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public void* MyVoidStarMethod() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Preview.cs new file mode 100644 index 00000000..02a3d2ff --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.CSharp.Preview.cs @@ -0,0 +1,30 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + public void MyVoidMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + [return: NativeTypeName("signed char")] + public sbyte MyInt8Method() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public int MyInt32Method() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + public void* MyVoidStarMethod() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Compatible.xml new file mode 100644 index 00000000..27dcea21 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Compatible.xml @@ -0,0 +1,70 @@ + + + + + + void** + + + void + + MyStruct* + + + + sbyte + + MyStruct* + + + + int + + MyStruct* + + + + void* + + MyStruct* + + + + void + + fixed (MyStruct* pThis = &this) + { + Marshal.GetDelegateForFunctionPointer<_MyVoidMethod>((IntPtr)(lpVtbl[0]))(pThis); + } + + + + sbyte + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_MyInt8Method>((IntPtr)(lpVtbl[1]))(pThis); + } + + + + int + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_MyInt32Method>((IntPtr)(lpVtbl[2]))(pThis); + } + + + + void* + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_MyVoidStarMethod>((IntPtr)(lpVtbl[3]))(pThis); + } + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Default.xml new file mode 100644 index 00000000..1c89828b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Default.xml @@ -0,0 +1,34 @@ + + + + + + void** + + + void + + ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + sbyte + + return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + void* + + return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Latest.xml new file mode 100644 index 00000000..1c89828b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Latest.xml @@ -0,0 +1,34 @@ + + + + + + void** + + + void + + ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + sbyte + + return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + void* + + return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Preview.xml new file mode 100644 index 00000000..1c89828b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualTest.Xml.Preview.xml @@ -0,0 +1,34 @@ + + + + + + void** + + + void + + ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + sbyte + + return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + void* + + return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Compatible.cs new file mode 100644 index 00000000..8de7b2a2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Compatible.cs @@ -0,0 +1,60 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate void _MyVoidMethod(MyStruct* pThis); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + [return: NativeTypeName("signed char")] + public delegate sbyte _MyInt8Method(MyStruct* pThis); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate int _MyInt32Method(MyStruct* pThis); + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate void* _MyVoidStarMethod(MyStruct* pThis); + + [VtblIndex(0)] + public void MyVoidMethod() + { + fixed (MyStruct* pThis = &this) + { + Marshal.GetDelegateForFunctionPointer<_MyVoidMethod>((IntPtr)(lpVtbl[0]))(pThis); + } + } + + [VtblIndex(1)] + [return: NativeTypeName("signed char")] + public sbyte MyInt8Method() + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_MyInt8Method>((IntPtr)(lpVtbl[1]))(pThis); + } + } + + [VtblIndex(2)] + public int MyInt32Method() + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_MyInt32Method>((IntPtr)(lpVtbl[2]))(pThis); + } + } + + [VtblIndex(3)] + public void* MyVoidStarMethod() + { + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_MyVoidStarMethod>((IntPtr)(lpVtbl[3]))(pThis); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Default.cs new file mode 100644 index 00000000..364d9d57 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Default.cs @@ -0,0 +1,34 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + [VtblIndex(0)] + public void MyVoidMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + [VtblIndex(1)] + [return: NativeTypeName("signed char")] + public sbyte MyInt8Method() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + [VtblIndex(2)] + public int MyInt32Method() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + [VtblIndex(3)] + public void* MyVoidStarMethod() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Latest.cs new file mode 100644 index 00000000..364d9d57 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Latest.cs @@ -0,0 +1,34 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + [VtblIndex(0)] + public void MyVoidMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + [VtblIndex(1)] + [return: NativeTypeName("signed char")] + public sbyte MyInt8Method() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + [VtblIndex(2)] + public int MyInt32Method() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + [VtblIndex(3)] + public void* MyVoidStarMethod() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Preview.cs new file mode 100644 index 00000000..364d9d57 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.CSharp.Preview.cs @@ -0,0 +1,34 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public void** lpVtbl; + + [VtblIndex(0)] + public void MyVoidMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + [VtblIndex(1)] + [return: NativeTypeName("signed char")] + public sbyte MyInt8Method() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + [VtblIndex(2)] + public int MyInt32Method() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + + [VtblIndex(3)] + public void* MyVoidStarMethod() + { + return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Compatible.xml new file mode 100644 index 00000000..41f836ed --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Compatible.xml @@ -0,0 +1,70 @@ + + + + + + void** + + + void + + MyStruct* + + + + sbyte + + MyStruct* + + + + int + + MyStruct* + + + + void* + + MyStruct* + + + + void + + fixed (MyStruct* pThis = &this) + { + Marshal.GetDelegateForFunctionPointer<_MyVoidMethod>((IntPtr)(lpVtbl[0]))(pThis); + } + + + + sbyte + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_MyInt8Method>((IntPtr)(lpVtbl[1]))(pThis); + } + + + + int + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_MyInt32Method>((IntPtr)(lpVtbl[2]))(pThis); + } + + + + void* + + fixed (MyStruct* pThis = &this) + { + return Marshal.GetDelegateForFunctionPointer<_MyVoidStarMethod>((IntPtr)(lpVtbl[3]))(pThis); + } + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Default.xml new file mode 100644 index 00000000..0b4addc7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Default.xml @@ -0,0 +1,34 @@ + + + + + + void** + + + void + + ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + sbyte + + return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + void* + + return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Latest.xml new file mode 100644 index 00000000..0b4addc7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Latest.xml @@ -0,0 +1,34 @@ + + + + + + void** + + + void + + ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + sbyte + + return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + void* + + return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Preview.xml new file mode 100644 index 00000000..0b4addc7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/CXXMethodDeclaration/VirtualWithVtblIndexAttributeTest.Xml.Preview.xml @@ -0,0 +1,34 @@ + + + + + + void** + + + void + + ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + sbyte + + return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + int + + return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + void* + + return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/EnumDecl.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/EnumDecl.CSharp.cs new file mode 100644 index 00000000..bff18e4a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/EnumDecl.CSharp.cs @@ -0,0 +1,26 @@ +using System; + +namespace ClangSharp.Test +{ + public enum MyEnum0 + { + MyEnum_Value0, + } + + [Obsolete] + public enum MyEnum1 + { + MyEnum_Value1, + } + + [Obsolete("This is obsolete.")] + public enum MyEnum2 + { + MyEnum_Value2, + } + + public enum MyEnum3 + { + MyEnum_Value3, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/EnumDecl.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/EnumDecl.Xml.xml new file mode 100644 index 00000000..ed2eb06b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/EnumDecl.Xml.xml @@ -0,0 +1,31 @@ + + + + + int + + int + + + + Obsolete + int + + int + + + + Obsolete("This is obsolete.") + int + + int + + + + int + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDecl.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDecl.CSharp.cs new file mode 100644 index 00000000..c5e4704b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDecl.CSharp.cs @@ -0,0 +1,25 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static void MyFunction0() + { + } + + [Obsolete] + public static void MyFunction1() + { + } + + [Obsolete("This is obsolete.")] + public static void MyFunction2() + { + } + + public static void MyFunction3() + { + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDecl.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDecl.Xml.xml new file mode 100644 index 00000000..e4cf47e1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDecl.Xml.xml @@ -0,0 +1,25 @@ + + + + + + void + + + + Obsolete + void + + + + Obsolete("This is obsolete.") + void + + + + void + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDeclDllImport.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDeclDllImport.CSharp.cs new file mode 100644 index 00000000..896dacec --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDeclDllImport.CSharp.cs @@ -0,0 +1,22 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction0(); + + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [Obsolete] + public static extern void MyFunction1(); + + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [Obsolete("This is obsolete.")] + public static extern void MyFunction2(); + + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction3(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDeclDllImport.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDeclDllImport.Xml.xml new file mode 100644 index 00000000..578c0cc6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncDeclDllImport.Xml.xml @@ -0,0 +1,21 @@ + + + + + + void + + + Obsolete + void + + + Obsolete("This is obsolete.") + void + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Compatible.cs new file mode 100644 index 00000000..00b40b30 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Compatible.cs @@ -0,0 +1,45 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void Callback0(); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + [Obsolete] + public delegate void Callback1(); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + [Obsolete("This is obsolete.")] + public delegate void Callback2(); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void Callback3(); + + public partial struct MyStruct0 + { + [NativeTypeName("Callback0")] + public IntPtr _callback; + } + + public partial struct MyStruct1 + { + [NativeTypeName("Callback1")] + [Obsolete] + public IntPtr _callback; + } + + public partial struct MyStruct2 + { + [NativeTypeName("Callback2")] + [Obsolete("This is obsolete.")] + public IntPtr _callback; + } + + public partial struct MyStruct3 + { + [NativeTypeName("Callback3")] + public IntPtr _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Default.cs new file mode 100644 index 00000000..75bb08ee --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Default.cs @@ -0,0 +1,30 @@ +using System; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct0 + { + [NativeTypeName("Callback0")] + public delegate* unmanaged[Cdecl] _callback; + } + + public unsafe partial struct MyStruct1 + { + [NativeTypeName("Callback1")] + [Obsolete] + public delegate* unmanaged[Cdecl] _callback; + } + + public unsafe partial struct MyStruct2 + { + [NativeTypeName("Callback2")] + [Obsolete("This is obsolete.")] + public delegate* unmanaged[Cdecl] _callback; + } + + public unsafe partial struct MyStruct3 + { + [NativeTypeName("Callback3")] + public delegate* unmanaged[Cdecl] _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Latest.cs new file mode 100644 index 00000000..75bb08ee --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Latest.cs @@ -0,0 +1,30 @@ +using System; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct0 + { + [NativeTypeName("Callback0")] + public delegate* unmanaged[Cdecl] _callback; + } + + public unsafe partial struct MyStruct1 + { + [NativeTypeName("Callback1")] + [Obsolete] + public delegate* unmanaged[Cdecl] _callback; + } + + public unsafe partial struct MyStruct2 + { + [NativeTypeName("Callback2")] + [Obsolete("This is obsolete.")] + public delegate* unmanaged[Cdecl] _callback; + } + + public unsafe partial struct MyStruct3 + { + [NativeTypeName("Callback3")] + public delegate* unmanaged[Cdecl] _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Preview.cs new file mode 100644 index 00000000..75bb08ee --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.CSharp.Preview.cs @@ -0,0 +1,30 @@ +using System; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct0 + { + [NativeTypeName("Callback0")] + public delegate* unmanaged[Cdecl] _callback; + } + + public unsafe partial struct MyStruct1 + { + [NativeTypeName("Callback1")] + [Obsolete] + public delegate* unmanaged[Cdecl] _callback; + } + + public unsafe partial struct MyStruct2 + { + [NativeTypeName("Callback2")] + [Obsolete("This is obsolete.")] + public delegate* unmanaged[Cdecl] _callback; + } + + public unsafe partial struct MyStruct3 + { + [NativeTypeName("Callback3")] + public delegate* unmanaged[Cdecl] _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Compatible.xml new file mode 100644 index 00000000..c3355605 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Compatible.xml @@ -0,0 +1,41 @@ + + + + + void + + + Obsolete + void + + + Obsolete("This is obsolete.") + void + + + void + + + + IntPtr + + + + + Obsolete + IntPtr + + + + + Obsolete("This is obsolete.") + IntPtr + + + + + IntPtr + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Default.xml new file mode 100644 index 00000000..a3961046 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Default.xml @@ -0,0 +1,27 @@ + + + + + + delegate* unmanaged[Cdecl]<void> + + + + + Obsolete + delegate* unmanaged[Cdecl]<void> + + + + + Obsolete("This is obsolete.") + delegate* unmanaged[Cdecl]<void> + + + + + delegate* unmanaged[Cdecl]<void> + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Latest.xml new file mode 100644 index 00000000..a3961046 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Latest.xml @@ -0,0 +1,27 @@ + + + + + + delegate* unmanaged[Cdecl]<void> + + + + + Obsolete + delegate* unmanaged[Cdecl]<void> + + + + + Obsolete("This is obsolete.") + delegate* unmanaged[Cdecl]<void> + + + + + delegate* unmanaged[Cdecl]<void> + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Preview.xml new file mode 100644 index 00000000..a3961046 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/FuncPtrDecl.Xml.Preview.xml @@ -0,0 +1,27 @@ + + + + + + delegate* unmanaged[Cdecl]<void> + + + + + Obsolete + delegate* unmanaged[Cdecl]<void> + + + + + Obsolete("This is obsolete.") + delegate* unmanaged[Cdecl]<void> + + + + + delegate* unmanaged[Cdecl]<void> + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/InstanceFunc.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/InstanceFunc.CSharp.cs new file mode 100644 index 00000000..d98eec88 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/InstanceFunc.CSharp.cs @@ -0,0 +1,29 @@ +using System; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int MyFunction0() + { + return 0; + } + + [Obsolete] + public int MyFunction1() + { + return 0; + } + + [Obsolete("This is obsolete.")] + public int MyFunction2() + { + return 0; + } + + public int MyFunction3() + { + return 0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/InstanceFunc.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/InstanceFunc.Xml.xml new file mode 100644 index 00000000..31012923 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/InstanceFunc.Xml.xml @@ -0,0 +1,25 @@ + + + + + + int + return 0; + + + Obsolete + int + return 0; + + + Obsolete("This is obsolete.") + int + return 0; + + + int + return 0; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleEnumMembers.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleEnumMembers.CSharp.cs new file mode 100644 index 00000000..6da00c2a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleEnumMembers.CSharp.cs @@ -0,0 +1,14 @@ +using System; + +namespace ClangSharp.Test +{ + public enum MyEnum + { + MyEnum_Value0, + [Obsolete] + MyEnum_Value1, + [Obsolete("This is obsolete.")] + MyEnum_Value2, + MyEnum_Value3, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleEnumMembers.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleEnumMembers.Xml.xml new file mode 100644 index 00000000..f2a7a5db --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleEnumMembers.Xml.xml @@ -0,0 +1,22 @@ + + + + + int + + int + + + Obsolete + int + + + Obsolete("This is obsolete.") + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleStructMembers_int_5Fint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleStructMembers_int_5Fint.CSharp.cs new file mode 100644 index 00000000..405acaa7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleStructMembers_int_5Fint.CSharp.cs @@ -0,0 +1,17 @@ +using System; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int r; + + [Obsolete] + public int g; + + [Obsolete("This is obsolete.")] + public int b; + + public int a; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleStructMembers_int_5Fint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleStructMembers_int_5Fint.Xml.xml new file mode 100644 index 00000000..62451fd1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleStructMembers_int_5Fint.Xml.xml @@ -0,0 +1,21 @@ + + + + + + int + + + Obsolete + int + + + Obsolete("This is obsolete.") + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleTypedefStructMembers_int_5Fint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleTypedefStructMembers_int_5Fint.CSharp.cs new file mode 100644 index 00000000..405acaa7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleTypedefStructMembers_int_5Fint.CSharp.cs @@ -0,0 +1,17 @@ +using System; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int r; + + [Obsolete] + public int g; + + [Obsolete("This is obsolete.")] + public int b; + + public int a; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleTypedefStructMembers_int_5Fint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleTypedefStructMembers_int_5Fint.Xml.xml new file mode 100644 index 00000000..62451fd1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleTypedefStructMembers_int_5Fint.Xml.xml @@ -0,0 +1,21 @@ + + + + + + int + + + Obsolete + int + + + Obsolete("This is obsolete.") + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleVarDecl_int_5Fint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleVarDecl_int_5Fint.CSharp.cs new file mode 100644 index 00000000..34fffe69 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleVarDecl_int_5Fint.CSharp.cs @@ -0,0 +1,17 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyVariable0 = 0; + + [Obsolete] + public static int MyVariable1 = 0; + + [Obsolete("This is obsolete.")] + public static int MyVariable2 = 0; + + public static int MyVariable3 = 0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleVarDecl_int_5Fint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleVarDecl_int_5Fint.Xml.xml new file mode 100644 index 00000000..f830a1f0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/SimpleVarDecl_int_5Fint.Xml.xml @@ -0,0 +1,33 @@ + + + + + + int + + 0 + + + + Obsolete + int + + 0 + + + + Obsolete("This is obsolete.") + int + + 0 + + + + int + + 0 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/StructDecl.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/StructDecl.CSharp.cs new file mode 100644 index 00000000..faeadf2c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/StructDecl.CSharp.cs @@ -0,0 +1,26 @@ +using System; + +namespace ClangSharp.Test +{ + public partial struct MyStruct0 + { + public int r; + } + + [Obsolete] + public partial struct MyStruct1 + { + public int r; + } + + [Obsolete("This is obsolete.")] + public partial struct MyStruct2 + { + public int r; + } + + public partial struct MyStruct3 + { + public int r; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/StructDecl.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/StructDecl.Xml.xml new file mode 100644 index 00000000..ffa4d12c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/StructDecl.Xml.xml @@ -0,0 +1,27 @@ + + + + + + int + + + + Obsolete + + int + + + + Obsolete("This is obsolete.") + + int + + + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/TypedefStructDecl.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/TypedefStructDecl.CSharp.cs new file mode 100644 index 00000000..faeadf2c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/TypedefStructDecl.CSharp.cs @@ -0,0 +1,26 @@ +using System; + +namespace ClangSharp.Test +{ + public partial struct MyStruct0 + { + public int r; + } + + [Obsolete] + public partial struct MyStruct1 + { + public int r; + } + + [Obsolete("This is obsolete.")] + public partial struct MyStruct2 + { + public int r; + } + + public partial struct MyStruct3 + { + public int r; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/TypedefStructDecl.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/TypedefStructDecl.Xml.xml new file mode 100644 index 00000000..ffa4d12c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedToObsolete/TypedefStructDecl.Xml.xml @@ -0,0 +1,27 @@ + + + + + + int + + + + Obsolete + + int + + + + Obsolete("This is obsolete.") + + int + + + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_2E0_5F1_5F024_2E0.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_2E0_5F1_5F024_2E0.CSharp.cs new file mode 100644 index 00000000..fea42c3f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_2E0_5F1_5F024_2E0.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public partial struct MyClass + { + [NativeTypeName("const float")] + private const float x = 1_024.0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_2E0_5F1_5F024_2E0.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_2E0_5F1_5F024_2E0.Xml.xml new file mode 100644 index 00000000..6295e038 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_2E0_5F1_5F024_2E0.Xml.xml @@ -0,0 +1,13 @@ + + + + + + float + + 1_024.0 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_5F1_5F024.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_5F1_5F024.CSharp.cs new file mode 100644 index 00000000..19fda2dc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_5F1_5F024.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public partial struct MyClass + { + [NativeTypeName("const float")] + private const float x = 1_024; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_5F1_5F024.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_5F1_5F024.Xml.xml new file mode 100644 index 00000000..aa894cd0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_float_5F1_27024_5F1_5F024.Xml.xml @@ -0,0 +1,13 @@ + + + + + + float + + 1_024 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27000_27001_5F1_5F000_5F001.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27000_27001_5F1_5F000_5F001.CSharp.cs new file mode 100644 index 00000000..7dc04436 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27000_27001_5F1_5F000_5F001.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public partial struct MyClass + { + [NativeTypeName("const int")] + private const int x = 1_000_001; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27000_27001_5F1_5F000_5F001.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27000_27001_5F1_5F000_5F001.Xml.xml new file mode 100644 index 00000000..d3a99a20 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27000_27001_5F1_5F000_5F001.Xml.xml @@ -0,0 +1,13 @@ + + + + + + int + + 1_000_001 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27024_5F1_5F024.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27024_5F1_5F024.CSharp.cs new file mode 100644 index 00000000..2eb64590 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27024_5F1_5F024.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public partial struct MyClass + { + [NativeTypeName("const int")] + private const int x = 1_024; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27024_5F1_5F024.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27024_5F1_5F024.Xml.xml new file mode 100644 index 00000000..88c7e78d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DigitsSeparator/StaticConstExprTest_int_5F1_27024_5F1_5F024.Xml.xml @@ -0,0 +1,13 @@ + + + + + + int + + 1_024 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicTest.CSharp.cs new file mode 100644 index 00000000..2fdb2f06 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicTest.CSharp.cs @@ -0,0 +1,9 @@ +namespace ClangSharp.Test +{ + public enum MyEnum + { + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicTest.Xml.xml new file mode 100644 index 00000000..f9df59a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicTest.Xml.xml @@ -0,0 +1,17 @@ + + + + + int + + int + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicValueTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicValueTest.CSharp.cs new file mode 100644 index 00000000..a2b01b2d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicValueTest.CSharp.cs @@ -0,0 +1,9 @@ +namespace ClangSharp.Test +{ + public enum MyEnum + { + MyEnum_Value1 = 1, + MyEnum_Value2, + MyEnum_Value3, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicValueTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicValueTest.Xml.xml new file mode 100644 index 00000000..05fb68d4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/BasicValueTest.Xml.xml @@ -0,0 +1,20 @@ + + + + + int + + int + + 1 + + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExcludeTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExcludeTest.CSharp.cs new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExcludeTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExcludeTest.Xml.xml new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedTest_short_5Fshort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedTest_short_5Fshort.CSharp.cs new file mode 100644 index 00000000..39444ef2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedTest_short_5Fshort.CSharp.cs @@ -0,0 +1,9 @@ +namespace ClangSharp.Test +{ + public enum MyEnum : short + { + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedTest_short_5Fshort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedTest_short_5Fshort.Xml.xml new file mode 100644 index 00000000..37f04fdc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedTest_short_5Fshort.Xml.xml @@ -0,0 +1,17 @@ + + + + + short + + short + + + short + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs new file mode 100644 index 00000000..016fbc5f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + [NativeTypeName("long long")] + public enum MyEnum : long + { + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_long_20long_5Flong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_long_20long_5Flong.Xml.xml new file mode 100644 index 00000000..599d4877 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_long_20long_5Flong.Xml.xml @@ -0,0 +1,17 @@ + + + + + long + + long + + + long + + + long + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs new file mode 100644 index 00000000..468387f1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + [NativeTypeName("signed char")] + public enum MyEnum : sbyte + { + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml new file mode 100644 index 00000000..d14a1566 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml @@ -0,0 +1,17 @@ + + + + + sbyte + + sbyte + + + sbyte + + + sbyte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs new file mode 100644 index 00000000..14cacb0b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + [NativeTypeName("unsigned char")] + public enum MyEnum : byte + { + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml new file mode 100644 index 00000000..f63a4d86 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml @@ -0,0 +1,17 @@ + + + + + byte + + byte + + + byte + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs new file mode 100644 index 00000000..0ed5362f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + [NativeTypeName("unsigned int")] + public enum MyEnum : uint + { + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml new file mode 100644 index 00000000..005e362f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml @@ -0,0 +1,17 @@ + + + + + uint + + uint + + + uint + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs new file mode 100644 index 00000000..9863a1d8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + [NativeTypeName("unsigned long long")] + public enum MyEnum : ulong + { + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml new file mode 100644 index 00000000..61d3c28b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml @@ -0,0 +1,17 @@ + + + + + ulong + + ulong + + + ulong + + + ulong + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs new file mode 100644 index 00000000..afca334d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + [NativeTypeName("unsigned short")] + public enum MyEnum : ushort + { + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml new file mode 100644 index 00000000..488775b9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/ExplicitTypedWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml @@ -0,0 +1,17 @@ + + + + + ushort + + ushort + + + ushort + + + ushort + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/RemapTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/RemapTest.CSharp.cs new file mode 100644 index 00000000..f4629b97 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/RemapTest.CSharp.cs @@ -0,0 +1,30 @@ +namespace ClangSharp.Test +{ + public enum MyEnum1 + { + MyEnum1_Value1, + MyEnum1_Value2, + MyEnum1_Value3, + } + + public enum MyEnum2 + { + MyEnum2_Value1, + MyEnum2_Value2, + MyEnum2_Value3, + } + + public enum MyEnum3 + { + MyEnum3_Value1, + MyEnum3_Value2, + MyEnum3_Value3, + } + + public enum MyEnum4 + { + MyEnum4_Value1, + MyEnum4_Value2, + MyEnum4_Value3, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/RemapTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/RemapTest.Xml.xml new file mode 100644 index 00000000..df2395fc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/RemapTest.Xml.xml @@ -0,0 +1,53 @@ + + + + + int + + int + + + int + + + int + + + + int + + int + + + int + + + int + + + + int + + int + + + int + + + int + + + + int + + int + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..1ba5fe8f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,14 @@ +using static ClangSharp.Test.Methods; + +namespace ClangSharp.Test +{ + public enum MyEnum2 + { + MyEnum2_Value1 = MyEnum1_Value1, + } + + public static partial class Methods + { + public const uint MyEnum1_Value1 = 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..4e3236cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Compatible.Windows.cs @@ -0,0 +1,14 @@ +using static ClangSharp.Test.Methods; + +namespace ClangSharp.Test +{ + public enum MyEnum2 + { + MyEnum2_Value1 = MyEnum1_Value1, + } + + public static partial class Methods + { + public const int MyEnum1_Value1 = 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..1ba5fe8f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Default.Unix.cs @@ -0,0 +1,14 @@ +using static ClangSharp.Test.Methods; + +namespace ClangSharp.Test +{ + public enum MyEnum2 + { + MyEnum2_Value1 = MyEnum1_Value1, + } + + public static partial class Methods + { + public const uint MyEnum1_Value1 = 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Default.Windows.cs new file mode 100644 index 00000000..4e3236cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Default.Windows.cs @@ -0,0 +1,14 @@ +using static ClangSharp.Test.Methods; + +namespace ClangSharp.Test +{ + public enum MyEnum2 + { + MyEnum2_Value1 = MyEnum1_Value1, + } + + public static partial class Methods + { + public const int MyEnum1_Value1 = 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..1ba5fe8f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Latest.Unix.cs @@ -0,0 +1,14 @@ +using static ClangSharp.Test.Methods; + +namespace ClangSharp.Test +{ + public enum MyEnum2 + { + MyEnum2_Value1 = MyEnum1_Value1, + } + + public static partial class Methods + { + public const uint MyEnum1_Value1 = 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..4e3236cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Latest.Windows.cs @@ -0,0 +1,14 @@ +using static ClangSharp.Test.Methods; + +namespace ClangSharp.Test +{ + public enum MyEnum2 + { + MyEnum2_Value1 = MyEnum1_Value1, + } + + public static partial class Methods + { + public const int MyEnum1_Value1 = 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..1ba5fe8f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Preview.Unix.cs @@ -0,0 +1,14 @@ +using static ClangSharp.Test.Methods; + +namespace ClangSharp.Test +{ + public enum MyEnum2 + { + MyEnum2_Value1 = MyEnum1_Value1, + } + + public static partial class Methods + { + public const uint MyEnum1_Value1 = 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..4e3236cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.CSharp.Preview.Windows.cs @@ -0,0 +1,14 @@ +using static ClangSharp.Test.Methods; + +namespace ClangSharp.Test +{ + public enum MyEnum2 + { + MyEnum2_Value1 = MyEnum1_Value1, + } + + public static partial class Methods + { + public const int MyEnum1_Value1 = 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..26f7ce06 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Compatible.Unix.xml @@ -0,0 +1,22 @@ + + + + + int + + int + + MyEnum1_Value1 + + + + + + uint + + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Compatible.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Compatible.Windows.xml new file mode 100644 index 00000000..4a4dc354 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Compatible.Windows.xml @@ -0,0 +1,22 @@ + + + + + int + + int + + MyEnum1_Value1 + + + + + + int + + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..26f7ce06 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Default.Unix.xml @@ -0,0 +1,22 @@ + + + + + int + + int + + MyEnum1_Value1 + + + + + + uint + + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Default.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Default.Windows.xml new file mode 100644 index 00000000..4a4dc354 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Default.Windows.xml @@ -0,0 +1,22 @@ + + + + + int + + int + + MyEnum1_Value1 + + + + + + int + + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..26f7ce06 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Latest.Unix.xml @@ -0,0 +1,22 @@ + + + + + int + + int + + MyEnum1_Value1 + + + + + + uint + + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Latest.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Latest.Windows.xml new file mode 100644 index 00000000..4a4dc354 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Latest.Windows.xml @@ -0,0 +1,22 @@ + + + + + int + + int + + MyEnum1_Value1 + + + + + + int + + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..26f7ce06 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Preview.Unix.xml @@ -0,0 +1,22 @@ + + + + + int + + int + + MyEnum1_Value1 + + + + + + uint + + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Preview.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Preview.Windows.xml new file mode 100644 index 00000000..4a4dc354 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAnonymousEnumTest.Xml.Preview.Windows.xml @@ -0,0 +1,22 @@ + + + + + int + + int + + MyEnum1_Value1 + + + + + + int + + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAttributeTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAttributeTest.CSharp.cs new file mode 100644 index 00000000..99f3c671 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAttributeTest.CSharp.cs @@ -0,0 +1,15 @@ +using System; + +namespace ClangSharp.Test +{ + [Flags] + public enum MyEnum1 + { + MyEnum1_Value1 = 1, + } + + public enum MyEnum2 + { + MyEnum2_Value1 = 1, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAttributeTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAttributeTest.Xml.xml new file mode 100644 index 00000000..342450a9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithAttributeTest.Xml.xml @@ -0,0 +1,24 @@ + + + + + Flags + int + + int + + 1 + + + + + int + + int + + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithCastToEnumType.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithCastToEnumType.CSharp.cs new file mode 100644 index 00000000..9970e625 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithCastToEnumType.CSharp.cs @@ -0,0 +1,9 @@ +namespace ClangSharp.Test +{ + public enum MyEnum + { + MyEnum_Value0 = (int)(MyEnum)(10), + MyEnum_Value1 = (int)(MyEnum)(MyEnum_Value0), + MyEnum_Value2 = ((int)(MyEnum)(10)) + MyEnum_Value1, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithCastToEnumType.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithCastToEnumType.Xml.xml new file mode 100644 index 00000000..7e684d84 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithCastToEnumType.Xml.xml @@ -0,0 +1,26 @@ + + + + + int + + int + + (int)(MyEnum)(10) + + + + int + + (int)(MyEnum)(MyEnum_Value0) + + + + int + + ((int)(MyEnum)(10)) + MyEnum_Value1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithImplicitConversionTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithImplicitConversionTest.CSharp.cs new file mode 100644 index 00000000..403d87a8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithImplicitConversionTest.CSharp.cs @@ -0,0 +1,9 @@ +namespace ClangSharp.Test +{ + public enum MyEnum + { + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2 = unchecked((int)(0x80000000)), + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithImplicitConversionTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithImplicitConversionTest.Xml.xml new file mode 100644 index 00000000..e662876c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithImplicitConversionTest.Xml.xml @@ -0,0 +1,27 @@ + + + + + int + + int + + + int + + + int + + + + int + + 0x80000000 + + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithMultipleEnumsTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithMultipleEnumsTest.CSharp.cs new file mode 100644 index 00000000..b7334681 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithMultipleEnumsTest.CSharp.cs @@ -0,0 +1,15 @@ +using static ClangSharp.Test.MyEnum1; + +namespace ClangSharp.Test +{ + public enum MyEnum1 + { + MyEnum1_Value0 = 10, + } + + public enum MyEnum2 + { + MyEnum2_Value0 = MyEnum1_Value0, + MyEnum2_Value1 = MyEnum1_Value0 + (int)(MyEnum1)(10), + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithMultipleEnumsTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithMultipleEnumsTest.Xml.xml new file mode 100644 index 00000000..246269d6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithMultipleEnumsTest.Xml.xml @@ -0,0 +1,29 @@ + + + + + int + + int + + 10 + + + + + int + + int + + MyEnum1_Value0 + + + + int + + MyEnum1_Value0 + (int)(MyEnum1)(10) + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarPlusTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarPlusTest.CSharp.cs new file mode 100644 index 00000000..9e34d3ae --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarPlusTest.CSharp.cs @@ -0,0 +1,15 @@ +using System; +using static ClangSharp.Test.MyEnum1; + +namespace ClangSharp.Test +{ + public enum MyEnum1 + { + MyEnum1_Value1 = 1, + } + + public enum MyEnum2 + { + MyEnum2_Value1 = MyEnum1_Value1, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarPlusTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarPlusTest.Xml.xml new file mode 100644 index 00000000..2accd163 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarPlusTest.Xml.xml @@ -0,0 +1,23 @@ + + + + + int + + int + + 1 + + + + + int + + int + + MyEnum1_Value1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarTest.CSharp.cs new file mode 100644 index 00000000..31d97b83 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarTest.CSharp.cs @@ -0,0 +1,14 @@ +using static ClangSharp.Test.MyEnum1; + +namespace ClangSharp.Test +{ + public enum MyEnum1 + { + MyEnum1_Value1 = 1, + } + + public enum MyEnum2 + { + MyEnum2_Value1 = MyEnum1_Value1, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarTest.Xml.xml new file mode 100644 index 00000000..2accd163 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceStarTest.Xml.xml @@ -0,0 +1,23 @@ + + + + + int + + int + + 1 + + + + + int + + int + + MyEnum1_Value1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceTest.CSharp.cs new file mode 100644 index 00000000..31d97b83 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceTest.CSharp.cs @@ -0,0 +1,14 @@ +using static ClangSharp.Test.MyEnum1; + +namespace ClangSharp.Test +{ + public enum MyEnum1 + { + MyEnum1_Value1 = 1, + } + + public enum MyEnum2 + { + MyEnum2_Value1 = MyEnum1_Value1, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceTest.Xml.xml new file mode 100644 index 00000000..2accd163 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithNamespaceTest.Xml.xml @@ -0,0 +1,23 @@ + + + + + int + + int + + 1 + + + + + int + + int + + MyEnum1_Value1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..2cd4bd84 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public const uint MyEnum1_Value1 = 1; + + [NativeTypeName("const int")] + public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..640829ab --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Compatible.Windows.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public const int MyEnum1_Value1 = 1; + + [NativeTypeName("const int")] + public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..2cd4bd84 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Default.Unix.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public const uint MyEnum1_Value1 = 1; + + [NativeTypeName("const int")] + public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Default.Windows.cs new file mode 100644 index 00000000..640829ab --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Default.Windows.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public const int MyEnum1_Value1 = 1; + + [NativeTypeName("const int")] + public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..2cd4bd84 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Latest.Unix.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public const uint MyEnum1_Value1 = 1; + + [NativeTypeName("const int")] + public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..640829ab --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Latest.Windows.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public const int MyEnum1_Value1 = 1; + + [NativeTypeName("const int")] + public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..2cd4bd84 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Preview.Unix.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public const uint MyEnum1_Value1 = 1; + + [NativeTypeName("const int")] + public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..640829ab --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.CSharp.Preview.Windows.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public const int MyEnum1_Value1 = 1; + + [NativeTypeName("const int")] + public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..b8274035 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Compatible.Unix.xml @@ -0,0 +1,19 @@ + + + + + + uint + + 1 + + + + int + + (int)(MyEnum1_Value1) + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Compatible.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Compatible.Windows.xml new file mode 100644 index 00000000..725ba5ff --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Compatible.Windows.xml @@ -0,0 +1,19 @@ + + + + + + int + + 1 + + + + int + + (int)(MyEnum1_Value1) + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..b8274035 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Default.Unix.xml @@ -0,0 +1,19 @@ + + + + + + uint + + 1 + + + + int + + (int)(MyEnum1_Value1) + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Default.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Default.Windows.xml new file mode 100644 index 00000000..725ba5ff --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Default.Windows.xml @@ -0,0 +1,19 @@ + + + + + + int + + 1 + + + + int + + (int)(MyEnum1_Value1) + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..b8274035 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Latest.Unix.xml @@ -0,0 +1,19 @@ + + + + + + uint + + 1 + + + + int + + (int)(MyEnum1_Value1) + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Latest.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Latest.Windows.xml new file mode 100644 index 00000000..725ba5ff --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Latest.Windows.xml @@ -0,0 +1,19 @@ + + + + + + int + + 1 + + + + int + + (int)(MyEnum1_Value1) + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..b8274035 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Preview.Unix.xml @@ -0,0 +1,19 @@ + + + + + + uint + + 1 + + + + int + + (int)(MyEnum1_Value1) + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Preview.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Preview.Windows.xml new file mode 100644 index 00000000..725ba5ff --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithReferenceToAnonymousEnumEnumeratorTest.Xml.Preview.Windows.xml @@ -0,0 +1,19 @@ + + + + + + int + + 1 + + + + int + + (int)(MyEnum1_Value1) + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeAndImplicitConversionTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeAndImplicitConversionTest.CSharp.cs new file mode 100644 index 00000000..de571b8f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeAndImplicitConversionTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + [NativeTypeName("int")] + public enum MyEnum : uint + { + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2 = 0x80000000, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeAndImplicitConversionTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeAndImplicitConversionTest.Xml.xml new file mode 100644 index 00000000..af859643 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeAndImplicitConversionTest.Xml.xml @@ -0,0 +1,20 @@ + + + + + uint + + uint + + + uint + + + uint + + 0x80000000 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarOverrideTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarOverrideTest.CSharp.cs new file mode 100644 index 00000000..659d112c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarOverrideTest.CSharp.cs @@ -0,0 +1,13 @@ +namespace ClangSharp.Test +{ + public enum MyEnum1 + { + MyEnum1_Value0, + } + + [NativeTypeName("int")] + public enum MyEnum2 : uint + { + MyEnum2_Value0, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarOverrideTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarOverrideTest.Xml.xml new file mode 100644 index 00000000..002e9e19 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarOverrideTest.Xml.xml @@ -0,0 +1,17 @@ + + + + + int + + int + + + + uint + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarTest.CSharp.cs new file mode 100644 index 00000000..5bd310a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarTest.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + [NativeTypeName("int")] + public enum MyEnum1 : uint + { + MyEnum1_Value0, + } + + [NativeTypeName("int")] + public enum MyEnum2 : uint + { + MyEnum2_Value0, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarTest.Xml.xml new file mode 100644 index 00000000..ef4accb4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeStarTest.Xml.xml @@ -0,0 +1,17 @@ + + + + + uint + + uint + + + + uint + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeTest.CSharp.cs new file mode 100644 index 00000000..092a29dc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + [NativeTypeName("int")] + public enum MyEnum : uint + { + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeTest.Xml.xml new file mode 100644 index 00000000..005e362f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/EnumDeclaration/WithTypeTest.Xml.xml @@ -0,0 +1,17 @@ + + + + + uint + + uint + + + uint + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Compatible.cs new file mode 100644 index 00000000..3cfe222f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Compatible.cs @@ -0,0 +1,38 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C5")] + public _Anonymous_e__Struct Anonymous; + + public ref int a + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->a; + } + } + } + + public partial struct _Anonymous_e__Struct + { + public int a; + } + } + + public static partial class Methods + { + public static void MyFunction() + { + MyUnion myUnion = new MyUnion(); + + myUnion.Anonymous.a = 10; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Default.cs new file mode 100644 index 00000000..d0cd9021 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Default.cs @@ -0,0 +1,37 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int a + { + get + { + return ref Anonymous.a; + } + } + + public partial struct _Anonymous_e__Struct + { + public int a; + } + } + + public static partial class Methods + { + public static void MyFunction() + { + MyUnion myUnion = new MyUnion(); + + myUnion.Anonymous.a = 10; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Latest.cs new file mode 100644 index 00000000..d0cd9021 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Latest.cs @@ -0,0 +1,37 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int a + { + get + { + return ref Anonymous.a; + } + } + + public partial struct _Anonymous_e__Struct + { + public int a; + } + } + + public static partial class Methods + { + public static void MyFunction() + { + MyUnion myUnion = new MyUnion(); + + myUnion.Anonymous.a = 10; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Preview.cs new file mode 100644 index 00000000..d0cd9021 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.CSharp.Preview.cs @@ -0,0 +1,37 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int a + { + get + { + return ref Anonymous.a; + } + } + + public partial struct _Anonymous_e__Struct + { + public int a; + } + } + + public static partial class Methods + { + public static void MyFunction() + { + MyUnion myUnion = new MyUnion(); + + myUnion.Anonymous.a = 10; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Compatible.xml new file mode 100644 index 00000000..06828316 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Compatible.xml @@ -0,0 +1,32 @@ + + + + + + _Anonymous_e__Struct + + + ref int + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->a; + } + + + + + int + + + + + + void + MyUnion myUnion = new MyUnion(); + + myUnion.Anonymous.a = 10; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Default.xml new file mode 100644 index 00000000..dabae223 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Default.xml @@ -0,0 +1,29 @@ + + + + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.a; + + + + + int + + + + + + void + MyUnion myUnion = new MyUnion(); + + myUnion.Anonymous.a = 10; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Latest.xml new file mode 100644 index 00000000..dabae223 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Latest.xml @@ -0,0 +1,29 @@ + + + + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.a; + + + + + int + + + + + + void + MyUnion myUnion = new MyUnion(); + + myUnion.Anonymous.a = 10; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Preview.xml new file mode 100644 index 00000000..dabae223 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/AccessUnionMemberTest.Xml.Preview.xml @@ -0,0 +1,29 @@ + + + + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.a; + + + + + int + + + + + + void + MyUnion myUnion = new MyUnion(); + + myUnion.Anonymous.a = 10; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ArraySubscriptTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ArraySubscriptTest.CSharp.cs new file mode 100644 index 00000000..ad4fe443 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ArraySubscriptTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + public static int MyFunction(int* pData, int index) + { + return pData[index]; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ArraySubscriptTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ArraySubscriptTest.Xml.xml new file mode 100644 index 00000000..90c7ba99 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ArraySubscriptTest.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int* + + + int + + return pData[index]; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BasicTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BasicTest.CSharp.cs new file mode 100644 index 00000000..68762ff7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BasicTest.CSharp.cs @@ -0,0 +1,9 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static void MyFunction() + { + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BasicTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BasicTest.Xml.xml new file mode 100644 index 00000000..9d7e1575 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BasicTest.Xml.xml @@ -0,0 +1,11 @@ + + + + + + void + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25.CSharp.cs new file mode 100644 index 00000000..4da2b4bb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x % y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25.Xml.xml new file mode 100644 index 00000000..044ceb7a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x % y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25_3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25_3D.CSharp.cs new file mode 100644 index 00000000..72e36e91 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25_3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x %= y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25_3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25_3D.Xml.xml new file mode 100644 index 00000000..a9b11f35 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__25_3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x %= y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26.CSharp.cs new file mode 100644 index 00000000..47d5830e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x & y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26.Xml.xml new file mode 100644 index 00000000..8a8285f3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x & y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26_3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26_3D.CSharp.cs new file mode 100644 index 00000000..d786db3f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26_3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x &= y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26_3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26_3D.Xml.xml new file mode 100644 index 00000000..6a3d3ef9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__26_3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x &= y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A.CSharp.cs new file mode 100644 index 00000000..785c82cd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x * y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A.Xml.xml new file mode 100644 index 00000000..ae471b1b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x * y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A_3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A_3D.CSharp.cs new file mode 100644 index 00000000..62a03115 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A_3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x *= y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A_3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A_3D.Xml.xml new file mode 100644 index 00000000..0d2ba5c0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2A_3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x *= y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B.CSharp.cs new file mode 100644 index 00000000..d2a42be1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x + y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B.Xml.xml new file mode 100644 index 00000000..2e3943b9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x + y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B_3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B_3D.CSharp.cs new file mode 100644 index 00000000..0fa06060 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B_3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x += y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B_3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B_3D.Xml.xml new file mode 100644 index 00000000..e590b55c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2B_3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x += y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D.CSharp.cs new file mode 100644 index 00000000..5bcdd615 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x - y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D.Xml.xml new file mode 100644 index 00000000..0794d0e1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x - y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D_3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D_3D.CSharp.cs new file mode 100644 index 00000000..8d80a1cc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D_3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x -= y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D_3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D_3D.Xml.xml new file mode 100644 index 00000000..24ee63cc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2D_3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x -= y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F.CSharp.cs new file mode 100644 index 00000000..1375e4bd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x / y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F.Xml.xml new file mode 100644 index 00000000..a13997be --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x / y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F_3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F_3D.CSharp.cs new file mode 100644 index 00000000..34e7b975 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F_3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x /= y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F_3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F_3D.Xml.xml new file mode 100644 index 00000000..0422c4ab --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__2F_3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x /= y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C.CSharp.cs new file mode 100644 index 00000000..15b8b654 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x << y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C.Xml.xml new file mode 100644 index 00000000..45707086 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x << y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C_3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C_3D.CSharp.cs new file mode 100644 index 00000000..78a80adf --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C_3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x <<= y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C_3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C_3D.Xml.xml new file mode 100644 index 00000000..819a82cd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3C_3C_3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x <<= y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3D.CSharp.cs new file mode 100644 index 00000000..c3cd2099 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x = y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3D.Xml.xml new file mode 100644 index 00000000..d6b5fa3a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x = y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E.CSharp.cs new file mode 100644 index 00000000..7bd9af47 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x >> y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E.Xml.xml new file mode 100644 index 00000000..61ead84c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x >> y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E_3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E_3D.CSharp.cs new file mode 100644 index 00000000..114dfe94 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E_3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x >>= y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E_3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E_3D.Xml.xml new file mode 100644 index 00000000..c8e42a8d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__3E_3E_3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x >>= y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E.CSharp.cs new file mode 100644 index 00000000..c5fe7077 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x ^ y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E.Xml.xml new file mode 100644 index 00000000..e8245844 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x ^ y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E_3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E_3D.CSharp.cs new file mode 100644 index 00000000..3195189b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E_3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x ^= y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E_3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E_3D.Xml.xml new file mode 100644 index 00000000..65188504 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__5E_3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x ^= y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C.CSharp.cs new file mode 100644 index 00000000..866b64a3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x | y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C.Xml.xml new file mode 100644 index 00000000..421fa861 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x | y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C_3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C_3D.CSharp.cs new file mode 100644 index 00000000..c719c190 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C_3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int x, int y) + { + return x |= y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C_3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C_3D.Xml.xml new file mode 100644 index 00000000..77484443 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBasicTest__7C_3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int + + int + + + int + + return x |= y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__26_26.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__26_26.CSharp.cs new file mode 100644 index 00000000..94478e5d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__26_26.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static bool MyFunction(bool x, bool y) + { + return x && y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__26_26.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__26_26.Xml.xml new file mode 100644 index 00000000..cee04571 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__26_26.Xml.xml @@ -0,0 +1,17 @@ + + + + + + bool + + bool + + + bool + + return x && y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__7C_7C.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__7C_7C.CSharp.cs new file mode 100644 index 00000000..800c8d60 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__7C_7C.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static bool MyFunction(bool x, bool y) + { + return x || y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__7C_7C.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__7C_7C.Xml.xml new file mode 100644 index 00000000..6ff94797 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorBooleanTest__7C_7C.Xml.xml @@ -0,0 +1,17 @@ + + + + + + bool + + bool + + + bool + + return x || y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__21_3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__21_3D.CSharp.cs new file mode 100644 index 00000000..297eb581 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__21_3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static bool MyFunction(int x, int y) + { + return x != y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__21_3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__21_3D.Xml.xml new file mode 100644 index 00000000..81dac47a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__21_3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + bool + + int + + + int + + return x != y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C.CSharp.cs new file mode 100644 index 00000000..8a62045c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static bool MyFunction(int x, int y) + { + return x < y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C.Xml.xml new file mode 100644 index 00000000..f69caa39 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C.Xml.xml @@ -0,0 +1,17 @@ + + + + + + bool + + int + + + int + + return x < y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C_3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C_3D.CSharp.cs new file mode 100644 index 00000000..a2e5eab8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C_3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static bool MyFunction(int x, int y) + { + return x <= y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C_3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C_3D.Xml.xml new file mode 100644 index 00000000..7ae8c808 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3C_3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + bool + + int + + + int + + return x <= y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3D_3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3D_3D.CSharp.cs new file mode 100644 index 00000000..0c94c881 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3D_3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static bool MyFunction(int x, int y) + { + return x == y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3D_3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3D_3D.Xml.xml new file mode 100644 index 00000000..bf0ba6e7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3D_3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + bool + + int + + + int + + return x == y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E.CSharp.cs new file mode 100644 index 00000000..2ab09b4e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static bool MyFunction(int x, int y) + { + return x > y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E.Xml.xml new file mode 100644 index 00000000..441d9508 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E.Xml.xml @@ -0,0 +1,17 @@ + + + + + + bool + + int + + + int + + return x > y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E_3D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E_3D.CSharp.cs new file mode 100644 index 00000000..7dcf453f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E_3D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static bool MyFunction(int x, int y) + { + return x >= y; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E_3D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E_3D.Xml.xml new file mode 100644 index 00000000..de135332 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BinaryOperatorCompareTest__3E_3D.Xml.xml @@ -0,0 +1,17 @@ + + + + + + bool + + int + + + int + + return x >= y; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BreakTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BreakTest.CSharp.cs new file mode 100644 index 00000000..210a914f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BreakTest.CSharp.cs @@ -0,0 +1,15 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int value) + { + while (true) + { + break; + } + + return 0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BreakTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BreakTest.Xml.xml new file mode 100644 index 00000000..b074d282 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/BreakTest.Xml.xml @@ -0,0 +1,19 @@ + + + + + + int + + int + + while (true) + { + break; + } + + return 0; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CStyleFunctionalCastTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CStyleFunctionalCastTest.CSharp.cs new file mode 100644 index 00000000..10bb563b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CStyleFunctionalCastTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(float input) + { + return (int)(input); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CStyleFunctionalCastTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CStyleFunctionalCastTest.Xml.xml new file mode 100644 index 00000000..ea58cedb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CStyleFunctionalCastTest.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int + + float + + return (int)(input); + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionTest.CSharp.cs new file mode 100644 index 00000000..edfc6a34 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionTest.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static void MyCalledFunction() + { + } + + public static void MyFunction() + { + MyCalledFunction(); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionTest.Xml.xml new file mode 100644 index 00000000..6f914d24 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionTest.Xml.xml @@ -0,0 +1,15 @@ + + + + + + void + + + + void + MyCalledFunction(); + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionWithArgsTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionWithArgsTest.CSharp.cs new file mode 100644 index 00000000..915731c1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionWithArgsTest.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static void MyCalledFunction(int x, int y) + { + } + + public static void MyFunction() + { + MyCalledFunction(0, 1); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionWithArgsTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionWithArgsTest.Xml.xml new file mode 100644 index 00000000..9f1ccbf0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CallFunctionWithArgsTest.Xml.xml @@ -0,0 +1,21 @@ + + + + + + void + + int + + + int + + + + + void + MyCalledFunction(0, 1); + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseNoCompoundTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseNoCompoundTest.CSharp.cs new file mode 100644 index 00000000..5455198a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseNoCompoundTest.CSharp.cs @@ -0,0 +1,24 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int value) + { + switch (value) + { + case 0: + { + return 0; + } + + case 2: + case 3: + { + return 5; + } + } + + return -1; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseNoCompoundTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseNoCompoundTest.Xml.xml new file mode 100644 index 00000000..ec4d7978 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseNoCompoundTest.Xml.xml @@ -0,0 +1,28 @@ + + + + + + int + + int + + switch (value) + { + case 0: + { + return 0; + } + + case 2: + case 3: + { + return 5; + } + } + + return -1; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseTest.CSharp.cs new file mode 100644 index 00000000..8bfda41b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseTest.CSharp.cs @@ -0,0 +1,24 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int value) + { + switch (value) + { + case 0: + { + return 0; + } + + case 1: + case 2: + { + return 3; + } + } + + return -1; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseTest.Xml.xml new file mode 100644 index 00000000..213f7724 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CaseTest.Xml.xml @@ -0,0 +1,28 @@ + + + + + + int + + int + + switch (value) + { + case 0: + { + return 0; + } + + case 1: + case 2: + { + return 3; + } + } + + return -1; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CompareMultipleEnumTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CompareMultipleEnumTest.CSharp.cs new file mode 100644 index 00000000..373b635a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CompareMultipleEnumTest.CSharp.cs @@ -0,0 +1,19 @@ +using static ClangSharp.Test.MyEnum; + +namespace ClangSharp.Test +{ + public enum MyEnum + { + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, + } + + public static partial class Methods + { + public static int MyFunction(MyEnum x) + { + return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CompareMultipleEnumTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CompareMultipleEnumTest.Xml.xml new file mode 100644 index 00000000..500b3b31 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CompareMultipleEnumTest.Xml.xml @@ -0,0 +1,26 @@ + + + + + int + + int + + + int + + + int + + + + + int + + MyEnum + + return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ConditionalOperatorTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ConditionalOperatorTest.CSharp.cs new file mode 100644 index 00000000..c6d43d85 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ConditionalOperatorTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(bool condition, int lhs, int rhs) + { + return condition ? lhs : rhs; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ConditionalOperatorTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ConditionalOperatorTest.Xml.xml new file mode 100644 index 00000000..97ea7e10 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ConditionalOperatorTest.Xml.xml @@ -0,0 +1,20 @@ + + + + + + int + + bool + + + int + + + int + + return condition ? lhs : rhs; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ContinueTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ContinueTest.CSharp.cs new file mode 100644 index 00000000..c01ed821 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ContinueTest.CSharp.cs @@ -0,0 +1,15 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int value) + { + while (true) + { + continue; + } + + return 0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ContinueTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ContinueTest.Xml.xml new file mode 100644 index 00000000..ef206625 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ContinueTest.Xml.xml @@ -0,0 +1,19 @@ + + + + + + int + + int + + while (true) + { + continue; + } + + return 0; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxConstCastTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxConstCastTest.CSharp.cs new file mode 100644 index 00000000..8cfe9f5f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxConstCastTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + public static void* MyFunction([NativeTypeName("const void *")] void* input) + { + return input; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxConstCastTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxConstCastTest.Xml.xml new file mode 100644 index 00000000..e28dfd48 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxConstCastTest.Xml.xml @@ -0,0 +1,14 @@ + + + + + + void* + + void* + + return input; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Compatible.cs new file mode 100644 index 00000000..9b949b10 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Compatible.cs @@ -0,0 +1,46 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStructA + { + public void** lpVtbl; + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate void _MyMethod(MyStructA* pThis); + + public void MyMethod() + { + fixed (MyStructA* pThis = &this) + { + Marshal.GetDelegateForFunctionPointer<_MyMethod>((IntPtr)(lpVtbl[0]))(pThis); + } + } + } + + [NativeTypeName("struct MyStructB : MyStructA")] + public unsafe partial struct MyStructB + { + public void** lpVtbl; + + [UnmanagedFunctionPointer(CallingConvention.ThisCall)] + public delegate void _MyMethod(MyStructB* pThis); + + public void MyMethod() + { + fixed (MyStructB* pThis = &this) + { + Marshal.GetDelegateForFunctionPointer<_MyMethod>((IntPtr)(lpVtbl[0]))(pThis); + } + } + } + + public static unsafe partial class Methods + { + public static MyStructB* MyFunction(MyStructA* input) + { + return (MyStructB*)(input); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Default.cs new file mode 100644 index 00000000..822b63f0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Default.cs @@ -0,0 +1,33 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStructA + { + public void** lpVtbl; + + public void MyMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); + } + } + + [NativeTypeName("struct MyStructB : MyStructA")] + public unsafe partial struct MyStructB + { + public void** lpVtbl; + + public void MyMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); + } + } + + public static unsafe partial class Methods + { + public static MyStructB* MyFunction(MyStructA* input) + { + return (MyStructB*)(input); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Latest.cs new file mode 100644 index 00000000..822b63f0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Latest.cs @@ -0,0 +1,33 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStructA + { + public void** lpVtbl; + + public void MyMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); + } + } + + [NativeTypeName("struct MyStructB : MyStructA")] + public unsafe partial struct MyStructB + { + public void** lpVtbl; + + public void MyMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); + } + } + + public static unsafe partial class Methods + { + public static MyStructB* MyFunction(MyStructA* input) + { + return (MyStructB*)(input); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Preview.cs new file mode 100644 index 00000000..822b63f0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.CSharp.Preview.cs @@ -0,0 +1,33 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStructA + { + public void** lpVtbl; + + public void MyMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); + } + } + + [NativeTypeName("struct MyStructB : MyStructA")] + public unsafe partial struct MyStructB + { + public void** lpVtbl; + + public void MyMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); + } + } + + public static unsafe partial class Methods + { + public static MyStructB* MyFunction(MyStructA* input) + { + return (MyStructB*)(input); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Compatible.xml new file mode 100644 index 00000000..71ec32f4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Compatible.xml @@ -0,0 +1,54 @@ + + + + + + void** + + + void + + MyStructA* + + + + void + + fixed (MyStructA* pThis = &this) + { + Marshal.GetDelegateForFunctionPointer<_MyMethod>((IntPtr)(lpVtbl[0]))(pThis); + } + + + + + + void** + + + void + + MyStructB* + + + + void + + fixed (MyStructB* pThis = &this) + { + Marshal.GetDelegateForFunctionPointer<_MyMethod>((IntPtr)(lpVtbl[0]))(pThis); + } + + + + + + MyStructB* + + MyStructA* + + return (MyStructB*)(input); + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Default.xml new file mode 100644 index 00000000..f9669ca6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Default.xml @@ -0,0 +1,36 @@ + + + + + + void** + + + void + + ((delegate* unmanaged[Thiscall]<MyStructA*, void>)(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); + + + + + + void** + + + void + + ((delegate* unmanaged[Thiscall]<MyStructB*, void>)(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); + + + + + + MyStructB* + + MyStructA* + + return (MyStructB*)(input); + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Latest.xml new file mode 100644 index 00000000..f9669ca6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Latest.xml @@ -0,0 +1,36 @@ + + + + + + void** + + + void + + ((delegate* unmanaged[Thiscall]<MyStructA*, void>)(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); + + + + + + void** + + + void + + ((delegate* unmanaged[Thiscall]<MyStructB*, void>)(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); + + + + + + MyStructB* + + MyStructA* + + return (MyStructB*)(input); + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Preview.xml new file mode 100644 index 00000000..f9669ca6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxDynamicCastTest.Xml.Preview.xml @@ -0,0 +1,36 @@ + + + + + + void** + + + void + + ((delegate* unmanaged[Thiscall]<MyStructA*, void>)(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); + + + + + + void** + + + void + + ((delegate* unmanaged[Thiscall]<MyStructB*, void>)(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); + + + + + + MyStructB* + + MyStructA* + + return (MyStructB*)(input); + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxFunctionalCastTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxFunctionalCastTest.CSharp.cs new file mode 100644 index 00000000..10bb563b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxFunctionalCastTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(float input) + { + return (int)(input); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxFunctionalCastTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxFunctionalCastTest.Xml.xml new file mode 100644 index 00000000..ea58cedb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxFunctionalCastTest.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int + + float + + return (int)(input); + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxReinterpretCastTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxReinterpretCastTest.CSharp.cs new file mode 100644 index 00000000..4c8db4a3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxReinterpretCastTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + public static int* MyFunction(void* input) + { + return (int*)(input); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxReinterpretCastTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxReinterpretCastTest.Xml.xml new file mode 100644 index 00000000..a126989a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxReinterpretCastTest.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int* + + void* + + return (int*)(input); + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxStaticCastTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxStaticCastTest.CSharp.cs new file mode 100644 index 00000000..4c8db4a3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxStaticCastTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + public static int* MyFunction(void* input) + { + return (int*)(input); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxStaticCastTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxStaticCastTest.Xml.xml new file mode 100644 index 00000000..a126989a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/CxxStaticCastTest.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int* + + void* + + return (int*)(input); + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DeclTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DeclTest.CSharp.cs new file mode 100644 index 00000000..06b3fbb2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DeclTest.CSharp.cs @@ -0,0 +1,13 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction() + { + int x = 0; + int y = 1, z = 2; + + return x + y + z; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DeclTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DeclTest.Xml.xml new file mode 100644 index 00000000..350b7d46 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DeclTest.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int + int x = 0; + int y = 1, z = 2; + + return x + y + z; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoNonCompoundTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoNonCompoundTest.CSharp.cs new file mode 100644 index 00000000..6b312efe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoNonCompoundTest.CSharp.cs @@ -0,0 +1,17 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int count) + { + int i = 0; + + while (i < count) + { + i++; + } + + return i; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoNonCompoundTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoNonCompoundTest.Xml.xml new file mode 100644 index 00000000..5ab45ec1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoNonCompoundTest.Xml.xml @@ -0,0 +1,21 @@ + + + + + + int + + int + + int i = 0; + + while (i < count) + { + i++; + } + + return i; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoTest.CSharp.cs new file mode 100644 index 00000000..f7a3d222 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoTest.CSharp.cs @@ -0,0 +1,18 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int count) + { + int i = 0; + + do + { + i++; + } + while (i < count); + + return i; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoTest.Xml.xml new file mode 100644 index 00000000..2bca7ca2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/DoTest.Xml.xml @@ -0,0 +1,22 @@ + + + + + + int + + int + + int i = 0; + + do + { + i++; + } + while (i < count); + + return i; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForNonCompoundTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForNonCompoundTest.CSharp.cs new file mode 100644 index 00000000..a2658360 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForNonCompoundTest.CSharp.cs @@ -0,0 +1,67 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int count) + { + for (int i = 0; i < count; i--) + { + i += 2; + } + + int x; + + for (x = 0; x < count; x--) + { + x += 2; + } + + x = 0; + for (; x < count; x--) + { + x += 2; + } + + for (int i = 0;; i--) + { + i += 2; + } + + for (x = 0;; x--) + { + x += 2; + } + + for (int i = 0; i < count;) + { + i++; + } + + for (x = 0; x < count;) + { + x++; + } + + x = 0; + for (; x < count;) + { + x++; + } + + for (int i = 0;;) + { + i++; + } + + for (x = 0;;) + { + x++; + } + + for (;;) + { + return -1; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForNonCompoundTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForNonCompoundTest.Xml.xml new file mode 100644 index 00000000..7bdb3bdb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForNonCompoundTest.Xml.xml @@ -0,0 +1,71 @@ + + + + + + int + + int + + for (int i = 0; i < count; i--) + { + i += 2; + } + + int x; + + for (x = 0; x < count; x--) + { + x += 2; + } + + x = 0; + for (; x < count; x--) + { + x += 2; + } + + for (int i = 0;; i--) + { + i += 2; + } + + for (x = 0;; x--) + { + x += 2; + } + + for (int i = 0; i < count;) + { + i++; + } + + for (x = 0; x < count;) + { + x++; + } + + x = 0; + for (; x < count;) + { + x++; + } + + for (int i = 0;;) + { + i++; + } + + for (x = 0;;) + { + x++; + } + + for (;;) + { + return -1; + } + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForTest.CSharp.cs new file mode 100644 index 00000000..a2658360 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForTest.CSharp.cs @@ -0,0 +1,67 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int count) + { + for (int i = 0; i < count; i--) + { + i += 2; + } + + int x; + + for (x = 0; x < count; x--) + { + x += 2; + } + + x = 0; + for (; x < count; x--) + { + x += 2; + } + + for (int i = 0;; i--) + { + i += 2; + } + + for (x = 0;; x--) + { + x += 2; + } + + for (int i = 0; i < count;) + { + i++; + } + + for (x = 0; x < count;) + { + x++; + } + + x = 0; + for (; x < count;) + { + x++; + } + + for (int i = 0;;) + { + i++; + } + + for (x = 0;;) + { + x++; + } + + for (;;) + { + return -1; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForTest.Xml.xml new file mode 100644 index 00000000..7bdb3bdb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ForTest.Xml.xml @@ -0,0 +1,71 @@ + + + + + + int + + int + + for (int i = 0; i < count; i--) + { + i += 2; + } + + int x; + + for (x = 0; x < count; x--) + { + x += 2; + } + + x = 0; + for (; x < count; x--) + { + x += 2; + } + + for (int i = 0;; i--) + { + i += 2; + } + + for (x = 0;; x--) + { + x += 2; + } + + for (int i = 0; i < count;) + { + i++; + } + + for (x = 0; x < count;) + { + x++; + } + + x = 0; + for (; x < count;) + { + x++; + } + + for (int i = 0;;) + { + i++; + } + + for (x = 0;;) + { + x++; + } + + for (;;) + { + return -1; + } + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseIfTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseIfTest.CSharp.cs new file mode 100644 index 00000000..32158b93 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseIfTest.CSharp.cs @@ -0,0 +1,19 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(bool condition1, int a, int b, bool condition2, int c) + { + if (condition1) + { + return a; + } + else if (condition2) + { + return b; + } + + return c; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseIfTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseIfTest.Xml.xml new file mode 100644 index 00000000..851bfb4f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseIfTest.Xml.xml @@ -0,0 +1,35 @@ + + + + + + int + + bool + + + int + + + int + + + bool + + + int + + if (condition1) + { + return a; + } + else if (condition2) + { + return b; + } + + return c; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseNonCompoundTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseNonCompoundTest.CSharp.cs new file mode 100644 index 00000000..9dd758ab --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseNonCompoundTest.CSharp.cs @@ -0,0 +1,17 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(bool condition, int lhs, int rhs) + { + if (condition) + { + return lhs; + } + else + { + return rhs; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseNonCompoundTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseNonCompoundTest.Xml.xml new file mode 100644 index 00000000..a0e537ca --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseNonCompoundTest.Xml.xml @@ -0,0 +1,27 @@ + + + + + + int + + bool + + + int + + + int + + if (condition) + { + return lhs; + } + else + { + return rhs; + } + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseTest.CSharp.cs new file mode 100644 index 00000000..9dd758ab --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseTest.CSharp.cs @@ -0,0 +1,17 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(bool condition, int lhs, int rhs) + { + if (condition) + { + return lhs; + } + else + { + return rhs; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseTest.Xml.xml new file mode 100644 index 00000000..a0e537ca --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfElseTest.Xml.xml @@ -0,0 +1,27 @@ + + + + + + int + + bool + + + int + + + int + + if (condition) + { + return lhs; + } + else + { + return rhs; + } + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfTest.CSharp.cs new file mode 100644 index 00000000..0dd6b07f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfTest.CSharp.cs @@ -0,0 +1,15 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(bool condition, int lhs, int rhs) + { + if (condition) + { + return lhs; + } + + return rhs; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfTest.Xml.xml new file mode 100644 index 00000000..64972354 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/IfTest.Xml.xml @@ -0,0 +1,25 @@ + + + + + + int + + bool + + + int + + + int + + if (condition) + { + return lhs; + } + + return rhs; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForArrayTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForArrayTest.CSharp.cs new file mode 100644 index 00000000..d192847d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForArrayTest.CSharp.cs @@ -0,0 +1,28 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static void MyFunction() + { + int[] x = new int[4] + { + 1, + 2, + 3, + 4, + }; + int[] y = new int[4] + { + 1, + 2, + 3, + default, + }; + int[] z = new int[2] + { + 1, + 2, + }; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForArrayTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForArrayTest.Xml.xml new file mode 100644 index 00000000..441a7326 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForArrayTest.Xml.xml @@ -0,0 +1,29 @@ + + + + + + void + int[] x = new int[4] + { + 1, + 2, + 3, + 4, + }; + int[] y = new int[4] + { + 1, + 2, + 3, + default, + }; + int[] z = new int[2] + { + 1, + 2, + }; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForRecordDeclTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForRecordDeclTest.CSharp.cs new file mode 100644 index 00000000..dbbad4f9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForRecordDeclTest.CSharp.cs @@ -0,0 +1,37 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float x; + + public float y; + + public float z; + + public float w; + } + + public static partial class Methods + { + public static MyStruct MyFunction1() + { + return new MyStruct + { + x = 1.0f, + y = 2.0f, + z = 3.0f, + w = 4.0f, + }; + } + + public static MyStruct MyFunction2() + { + return new MyStruct + { + x = 1.0f, + y = 2.0f, + z = 3.0f, + }; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForRecordDeclTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForRecordDeclTest.Xml.xml new file mode 100644 index 00000000..9d0602d9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/InitListForRecordDeclTest.Xml.xml @@ -0,0 +1,40 @@ + + + + + + float + + + float + + + float + + + float + + + + + MyStruct + return new MyStruct + { + x = 1.0f, + y = 2.0f, + z = 3.0f, + w = 4.0f, + }; + + + MyStruct + return new MyStruct + { + x = 1.0f, + y = 2.0f, + z = 3.0f, + }; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/MemberTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/MemberTest.CSharp.cs new file mode 100644 index 00000000..5648f3f4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/MemberTest.CSharp.cs @@ -0,0 +1,20 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public static unsafe partial class Methods + { + public static int MyFunction1(MyStruct instance) + { + return instance.value; + } + + public static int MyFunction2(MyStruct* instance) + { + return instance->value; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/MemberTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/MemberTest.Xml.xml new file mode 100644 index 00000000..a8432fcd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/MemberTest.Xml.xml @@ -0,0 +1,26 @@ + + + + + + int + + + + + int + + MyStruct + + return instance.value; + + + int + + MyStruct* + + return instance->value; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/RefToPtrTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/RefToPtrTest.CSharp.cs new file mode 100644 index 00000000..ed5080a4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/RefToPtrTest.CSharp.cs @@ -0,0 +1,15 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public static unsafe partial class Methods + { + public static bool MyFunction([NativeTypeName("const MyStruct &")] MyStruct* lhs, [NativeTypeName("const MyStruct &")] MyStruct* rhs) + { + return lhs->value == rhs->value; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/RefToPtrTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/RefToPtrTest.Xml.xml new file mode 100644 index 00000000..a9d3331c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/RefToPtrTest.Xml.xml @@ -0,0 +1,22 @@ + + + + + + int + + + + + bool + + MyStruct* + + + MyStruct* + + return lhs->value == rhs->value; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_false.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_false.CSharp.cs new file mode 100644 index 00000000..2f79bb94 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_false.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static bool MyFunction() + { + return false; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_false.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_false.Xml.xml new file mode 100644 index 00000000..d4f9a4aa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_false.Xml.xml @@ -0,0 +1,11 @@ + + + + + + bool + return false; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_true.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_true.CSharp.cs new file mode 100644 index 00000000..13af7f5f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_true.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static bool MyFunction() + { + return true; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_true.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_true.Xml.xml new file mode 100644 index 00000000..4cb527fd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXBooleanLiteralTest_true.Xml.xml @@ -0,0 +1,11 @@ + + + + + + bool + return true; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXNullPtrTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXNullPtrTest.CSharp.cs new file mode 100644 index 00000000..d45eaa35 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXNullPtrTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + public static void* MyFunction() + { + return null; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXNullPtrTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXNullPtrTest.Xml.xml new file mode 100644 index 00000000..68b582fb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnCXXNullPtrTest.Xml.xml @@ -0,0 +1,11 @@ + + + + + + void* + return null; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnEmptyTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnEmptyTest.CSharp.cs new file mode 100644 index 00000000..d9932ae3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnEmptyTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static void MyFunction() + { + return; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnEmptyTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnEmptyTest.Xml.xml new file mode 100644 index 00000000..3336bc32 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnEmptyTest.Xml.xml @@ -0,0 +1,11 @@ + + + + + + void + return; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_3_2E14.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_3_2E14.CSharp.cs new file mode 100644 index 00000000..0fb58439 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_3_2E14.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static double MyFunction() + { + return 3.14; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_3_2E14.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_3_2E14.Xml.xml new file mode 100644 index 00000000..6a49c02f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_3_2E14.Xml.xml @@ -0,0 +1,11 @@ + + + + + + double + return 3.14; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_5e_2D1.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_5e_2D1.CSharp.cs new file mode 100644 index 00000000..b2de5cb2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_5e_2D1.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static double MyFunction() + { + return 5e-1; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_5e_2D1.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_5e_2D1.Xml.xml new file mode 100644 index 00000000..ef9f1634 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralDoubleTest_5e_2D1.Xml.xml @@ -0,0 +1,11 @@ + + + + + + double + return 5e-1; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_3_2E14f.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_3_2E14f.CSharp.cs new file mode 100644 index 00000000..db455ead --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_3_2E14f.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static float MyFunction() + { + return 3.14f; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_3_2E14f.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_3_2E14f.Xml.xml new file mode 100644 index 00000000..8cf7ce22 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_3_2E14f.Xml.xml @@ -0,0 +1,11 @@ + + + + + + float + return 3.14f; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_5e_2D1f.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_5e_2D1f.CSharp.cs new file mode 100644 index 00000000..1b98eab9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_5e_2D1f.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static float MyFunction() + { + return 5e-1f; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_5e_2D1f.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_5e_2D1f.Xml.xml new file mode 100644 index 00000000..faeff00a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnFloatingLiteralSingleTest_5e_2D1f.Xml.xml @@ -0,0 +1,11 @@ + + + + + + float + return 5e-1f; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnIntegerLiteralInt32Test.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnIntegerLiteralInt32Test.CSharp.cs new file mode 100644 index 00000000..dc571a06 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnIntegerLiteralInt32Test.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction() + { + return -1; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnIntegerLiteralInt32Test.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnIntegerLiteralInt32Test.Xml.xml new file mode 100644 index 00000000..76ceb89c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnIntegerLiteralInt32Test.Xml.xml @@ -0,0 +1,11 @@ + + + + + + int + return -1; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnStructTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnStructTest.CSharp.cs new file mode 100644 index 00000000..bb51113c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnStructTest.CSharp.cs @@ -0,0 +1,21 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double r; + + public double g; + + public double b; + } + + public static partial class Methods + { + public static MyStruct MyFunction() + { + MyStruct myStruct = new MyStruct(); + + return myStruct; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnStructTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnStructTest.Xml.xml new file mode 100644 index 00000000..e2c85b7e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/ReturnStructTest.Xml.xml @@ -0,0 +1,24 @@ + + + + + + double + + + double + + + double + + + + + MyStruct + MyStruct myStruct = new MyStruct(); + + return myStruct; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchNonCompoundTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchNonCompoundTest.CSharp.cs new file mode 100644 index 00000000..213265e2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchNonCompoundTest.CSharp.cs @@ -0,0 +1,24 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int value) + { + switch (value) + { + default: + { + return 0; + } + } + + switch (value) + { + default: + { + return 0; + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchNonCompoundTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchNonCompoundTest.Xml.xml new file mode 100644 index 00000000..076dae80 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchNonCompoundTest.Xml.xml @@ -0,0 +1,28 @@ + + + + + + int + + int + + switch (value) + { + default: + { + return 0; + } + } + + switch (value) + { + default: + { + return 0; + } + } + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchTest.CSharp.cs new file mode 100644 index 00000000..e5def936 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchTest.CSharp.cs @@ -0,0 +1,16 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int value) + { + switch (value) + { + default: + { + return 0; + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchTest.Xml.xml new file mode 100644 index 00000000..0acdee5c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/SwitchTest.Xml.xml @@ -0,0 +1,20 @@ + + + + + + int + + int + + switch (value) + { + default: + { + return 0; + } + } + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorAddrOfTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorAddrOfTest.CSharp.cs new file mode 100644 index 00000000..95cc1940 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorAddrOfTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + public static int* MyFunction(int value) + { + return &value; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorAddrOfTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorAddrOfTest.Xml.xml new file mode 100644 index 00000000..0f4fadaa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorAddrOfTest.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int* + + int + + return &value; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorDerefTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorDerefTest.CSharp.cs new file mode 100644 index 00000000..db32f4eb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorDerefTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + public static int MyFunction(int* value) + { + return *value; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorDerefTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorDerefTest.Xml.xml new file mode 100644 index 00000000..c4af7b6f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorDerefTest.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int + + int* + + return *value; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorLogicalNotTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorLogicalNotTest.CSharp.cs new file mode 100644 index 00000000..30ce0438 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorLogicalNotTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static bool MyFunction(bool value) + { + return !value; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorLogicalNotTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorLogicalNotTest.Xml.xml new file mode 100644 index 00000000..aa1d0d9e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorLogicalNotTest.Xml.xml @@ -0,0 +1,14 @@ + + + + + + bool + + bool + + return !value; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2B_2B.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2B_2B.CSharp.cs new file mode 100644 index 00000000..4464bc18 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2B_2B.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int value) + { + return value++; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2B_2B.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2B_2B.Xml.xml new file mode 100644 index 00000000..30c8561e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2B_2B.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int + + int + + return value++; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2D_2D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2D_2D.CSharp.cs new file mode 100644 index 00000000..513691d8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2D_2D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int value) + { + return value--; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2D_2D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2D_2D.Xml.xml new file mode 100644 index 00000000..2b060edb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPostfixTest__2D_2D.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int + + int + + return value--; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B.CSharp.cs new file mode 100644 index 00000000..ed8beab6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int value) + { + return +value; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B.Xml.xml new file mode 100644 index 00000000..e5f539ae --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int + + int + + return +value; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B_2B.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B_2B.CSharp.cs new file mode 100644 index 00000000..5401aa5c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B_2B.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int value) + { + return ++value; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B_2B.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B_2B.Xml.xml new file mode 100644 index 00000000..829c87e0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2B_2B.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int + + int + + return ++value; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D.CSharp.cs new file mode 100644 index 00000000..6ba428f2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int value) + { + return -value; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D.Xml.xml new file mode 100644 index 00000000..ef280ce3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int + + int + + return -value; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D_2D.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D_2D.CSharp.cs new file mode 100644 index 00000000..ce701c08 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D_2D.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int value) + { + return --value; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D_2D.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D_2D.Xml.xml new file mode 100644 index 00000000..4d04e391 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__2D_2D.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int + + int + + return --value; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__7E.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__7E.CSharp.cs new file mode 100644 index 00000000..08e3ad37 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__7E.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int value) + { + return ~value; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__7E.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__7E.Xml.xml new file mode 100644 index 00000000..2052122e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/UnaryOperatorPrefixTest__7E.Xml.xml @@ -0,0 +1,14 @@ + + + + + + int + + int + + return ~value; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileNonCompoundTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileNonCompoundTest.CSharp.cs new file mode 100644 index 00000000..6b312efe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileNonCompoundTest.CSharp.cs @@ -0,0 +1,17 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int count) + { + int i = 0; + + while (i < count) + { + i++; + } + + return i; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileNonCompoundTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileNonCompoundTest.Xml.xml new file mode 100644 index 00000000..5ab45ec1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileNonCompoundTest.Xml.xml @@ -0,0 +1,21 @@ + + + + + + int + + int + + int i = 0; + + while (i < count) + { + i++; + } + + return i; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileTest.CSharp.cs new file mode 100644 index 00000000..6b312efe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileTest.CSharp.cs @@ -0,0 +1,17 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyFunction(int count) + { + int i = 0; + + while (i < count) + { + i++; + } + + return i; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileTest.Xml.xml new file mode 100644 index 00000000..5ab45ec1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationBodyImport/WhileTest.Xml.xml @@ -0,0 +1,21 @@ + + + + + + int + + int + + int i = 0; + + while (i < count) + { + i++; + } + + return i; + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/ArrayParameterTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/ArrayParameterTest.CSharp.cs new file mode 100644 index 00000000..cf956dad --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/ArrayParameterTest.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("const float[4]")] float* color); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/ArrayParameterTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/ArrayParameterTest.Xml.xml new file mode 100644 index 00000000..124f6df9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/ArrayParameterTest.Xml.xml @@ -0,0 +1,13 @@ + + + + + + void + + float* + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/BasicTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/BasicTest.CSharp.cs new file mode 100644 index 00000000..e1bfab2e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/BasicTest.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/BasicTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/BasicTest.Xml.xml new file mode 100644 index 00000000..1dfcf83d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/BasicTest.Xml.xml @@ -0,0 +1,10 @@ + + + + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Compatible.cs new file mode 100644 index 00000000..5aecb089 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Compatible.cs @@ -0,0 +1,11 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("void (*)()")] IntPtr callback); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Default.cs new file mode 100644 index 00000000..cae5558f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Default.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("void (*)()")] delegate* unmanaged[Cdecl] callback); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Latest.cs new file mode 100644 index 00000000..cae5558f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Latest.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("void (*)()")] delegate* unmanaged[Cdecl] callback); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Preview.cs new file mode 100644 index 00000000..cae5558f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.CSharp.Preview.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("void (*)()")] delegate* unmanaged[Cdecl] callback); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Compatible.xml new file mode 100644 index 00000000..d5241fe5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Compatible.xml @@ -0,0 +1,13 @@ + + + + + + void + + IntPtr + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Default.xml new file mode 100644 index 00000000..1e150afd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Default.xml @@ -0,0 +1,13 @@ + + + + + + void + + delegate* unmanaged[Cdecl]<void> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Latest.xml new file mode 100644 index 00000000..1e150afd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Latest.xml @@ -0,0 +1,13 @@ + + + + + + void + + delegate* unmanaged[Cdecl]<void> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Preview.xml new file mode 100644 index 00000000..1e150afd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/FunctionPointerParameterTest.Xml.Preview.xml @@ -0,0 +1,13 @@ + + + + + + void + + delegate* unmanaged[Cdecl]<void> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/IntrinsicsTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/IntrinsicsTest.CSharp.cs new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/IntrinsicsTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/IntrinsicsTest.Xml.xml new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..c8c39e8f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, EntryPoint = "_ZN11MyNamespace10MyFunctionEv", ExactSpelling = true)] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..c8c39e8f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Default.Unix.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, EntryPoint = "_ZN11MyNamespace10MyFunctionEv", ExactSpelling = true)] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..c8c39e8f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Latest.Unix.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, EntryPoint = "_ZN11MyNamespace10MyFunctionEv", ExactSpelling = true)] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..c8c39e8f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.Preview.Unix.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, EntryPoint = "_ZN11MyNamespace10MyFunctionEv", ExactSpelling = true)] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.cs new file mode 100644 index 00000000..4e9cf387 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, EntryPoint = "?MyFunction@MyNamespace@@YAXXZ", ExactSpelling = true)] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..3d7417e1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Compatible.Unix.xml @@ -0,0 +1,10 @@ + + + + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..3d7417e1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Default.Unix.xml @@ -0,0 +1,10 @@ + + + + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..3d7417e1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Latest.Unix.xml @@ -0,0 +1,10 @@ + + + + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..3d7417e1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.Preview.Unix.xml @@ -0,0 +1,10 @@ + + + + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.xml new file mode 100644 index 00000000..106886c3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NamespaceTest.Xml.xml @@ -0,0 +1,10 @@ + + + + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NoLibraryPathTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NoLibraryPathTest.CSharp.cs new file mode 100644 index 00000000..110bdece --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NoLibraryPathTest.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NoLibraryPathTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NoLibraryPathTest.Xml.xml new file mode 100644 index 00000000..3467d386 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/NoLibraryPathTest.Xml.xml @@ -0,0 +1,10 @@ + + + + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_double_5F1_2E0_5FFalse_5Fdouble_5F1_2E0.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_double_5F1_2E0_5FFalse_5Fdouble_5F1_2E0.CSharp.cs new file mode 100644 index 00000000..4f6962a9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_double_5F1_2E0_5FFalse_5Fdouble_5F1_2E0.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(double value = 1.0); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_double_5F1_2E0_5FFalse_5Fdouble_5F1_2E0.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_double_5F1_2E0_5FFalse_5Fdouble_5F1_2E0.Xml.xml new file mode 100644 index 00000000..434748da --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_double_5F1_2E0_5FFalse_5Fdouble_5F1_2E0.Xml.xml @@ -0,0 +1,16 @@ + + + + + + void + + double + + 1.0 + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_float_5F6_2E0f_5FFalse_5Ffloat_5F6_2E0f.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_float_5F6_2E0f_5FFalse_5Ffloat_5F6_2E0f.CSharp.cs new file mode 100644 index 00000000..8fee3301 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_float_5F6_2E0f_5FFalse_5Ffloat_5F6_2E0f.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(float value = 6.0f); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_float_5F6_2E0f_5FFalse_5Ffloat_5F6_2E0f.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_float_5F6_2E0f_5FFalse_5Ffloat_5F6_2E0f.Xml.xml new file mode 100644 index 00000000..ad872907 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_float_5F6_2E0f_5FFalse_5Ffloat_5F6_2E0f.Xml.xml @@ -0,0 +1,16 @@ + + + + + + void + + float + + 6.0f + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_int_5F3_5FFalse_5Fint_5F3.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_int_5F3_5FFalse_5Fint_5F3.CSharp.cs new file mode 100644 index 00000000..b457f236 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_int_5F3_5FFalse_5Fint_5F3.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(int value = 3); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_int_5F3_5FFalse_5Fint_5F3.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_int_5F3_5FFalse_5Fint_5F3.Xml.xml new file mode 100644 index 00000000..e1479328 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_int_5F3_5FFalse_5Fint_5F3.Xml.xml @@ -0,0 +1,16 @@ + + + + + + void + + int + + 3 + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_long_20long_5F4_5FTrue_5Flong_5F4.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_long_20long_5F4_5FTrue_5Flong_5F4.CSharp.cs new file mode 100644 index 00000000..6733966f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_long_20long_5F4_5FTrue_5Flong_5F4.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("long long")] long value = 4); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_long_20long_5F4_5FTrue_5Flong_5F4.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_long_20long_5F4_5FTrue_5Flong_5F4.Xml.xml new file mode 100644 index 00000000..a8289cca --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_long_20long_5F4_5FTrue_5Flong_5F4.Xml.xml @@ -0,0 +1,16 @@ + + + + + + void + + long + + 4 + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_short_5F2_5FFalse_5Fshort_5F2.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_short_5F2_5FFalse_5Fshort_5F2.CSharp.cs new file mode 100644 index 00000000..481abfcb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_short_5F2_5FFalse_5Fshort_5F2.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(short value = 2); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_short_5F2_5FFalse_5Fshort_5F2.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_short_5F2_5FFalse_5Fshort_5F2.Xml.xml new file mode 100644 index 00000000..d70108cd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_short_5F2_5FFalse_5Fshort_5F2.Xml.xml @@ -0,0 +1,16 @@ + + + + + + void + + short + + 2 + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_signed_20char_5F5_5FTrue_5Fsbyte_5F5.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_signed_20char_5F5_5FTrue_5Fsbyte_5F5.CSharp.cs new file mode 100644 index 00000000..e92ee043 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_signed_20char_5F5_5FTrue_5Fsbyte_5F5.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("signed char")] sbyte value = 5); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_signed_20char_5F5_5FTrue_5Fsbyte_5F5.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_signed_20char_5F5_5FTrue_5Fsbyte_5F5.Xml.xml new file mode 100644 index 00000000..e1e939f4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_signed_20char_5F5_5FTrue_5Fsbyte_5F5.Xml.xml @@ -0,0 +1,16 @@ + + + + + + void + + sbyte + + 5 + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20char_5F0_5FTrue_5Fbyte_5F0.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20char_5F0_5FTrue_5Fbyte_5F0.CSharp.cs new file mode 100644 index 00000000..f776ee3f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20char_5F0_5FTrue_5Fbyte_5F0.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("unsigned char")] byte value = 0); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20char_5F0_5FTrue_5Fbyte_5F0.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20char_5F0_5FTrue_5Fbyte_5F0.Xml.xml new file mode 100644 index 00000000..ded85895 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20char_5F0_5FTrue_5Fbyte_5F0.Xml.xml @@ -0,0 +1,16 @@ + + + + + + void + + byte + + 0 + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20int_5F8_5FTrue_5Fuint_5F8.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20int_5F8_5FTrue_5Fuint_5F8.CSharp.cs new file mode 100644 index 00000000..39fca763 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20int_5F8_5FTrue_5Fuint_5F8.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("unsigned int")] uint value = 8); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20int_5F8_5FTrue_5Fuint_5F8.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20int_5F8_5FTrue_5Fuint_5F8.Xml.xml new file mode 100644 index 00000000..06e86e5b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20int_5F8_5FTrue_5Fuint_5F8.Xml.xml @@ -0,0 +1,16 @@ + + + + + + void + + uint + + 8 + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20long_20long_5F9_5FTrue_5Fulong_5F9.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20long_20long_5F9_5FTrue_5Fulong_5F9.CSharp.cs new file mode 100644 index 00000000..dd6bff3f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20long_20long_5F9_5FTrue_5Fulong_5F9.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("unsigned long long")] ulong value = 9); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20long_20long_5F9_5FTrue_5Fulong_5F9.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20long_20long_5F9_5FTrue_5Fulong_5F9.Xml.xml new file mode 100644 index 00000000..a9dfb811 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20long_20long_5F9_5FTrue_5Fulong_5F9.Xml.xml @@ -0,0 +1,16 @@ + + + + + + void + + ulong + + 9 + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F7_5FTrue_5Fushort_5F7.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F7_5FTrue_5Fushort_5F7.CSharp.cs new file mode 100644 index 00000000..d00e0b33 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F7_5FTrue_5Fushort_5F7.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("unsigned short")] ushort value = 7); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F7_5FTrue_5Fushort_5F7.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F7_5FTrue_5Fushort_5F7.Xml.xml new file mode 100644 index 00000000..5b2ed8b4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F7_5FTrue_5Fushort_5F7.Xml.xml @@ -0,0 +1,16 @@ + + + + + + void + + ushort + + 7 + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F_27A_27_5FTrue_5Fushort_5F_28byte_29_28_27A_27_29.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F_27A_27_5FTrue_5Fushort_5F_28byte_29_28_27A_27_29.CSharp.cs new file mode 100644 index 00000000..53d3d607 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F_27A_27_5FTrue_5Fushort_5F_28byte_29_28_27A_27_29.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("unsigned short")] ushort value = (byte)('A')); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F_27A_27_5FTrue_5Fushort_5F_28byte_29_28_27A_27_29.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F_27A_27_5FTrue_5Fushort_5F_28byte_29_28_27A_27_29.Xml.xml new file mode 100644 index 00000000..2c3638e4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterTest_unsigned_20short_5F_27A_27_5FTrue_5Fushort_5F_28byte_29_28_27A_27_29.Xml.xml @@ -0,0 +1,16 @@ + + + + + + void + + ushort + + (byte)('A') + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5F0_5Fvoid_2A_5Fnull.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5F0_5Fvoid_2A_5Fnull.CSharp.cs new file mode 100644 index 00000000..e2ad5416 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5F0_5Fvoid_2A_5Fnull.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(void* value = null); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5F0_5Fvoid_2A_5Fnull.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5F0_5Fvoid_2A_5Fnull.Xml.xml new file mode 100644 index 00000000..29a1fe64 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5F0_5Fvoid_2A_5Fnull.Xml.xml @@ -0,0 +1,16 @@ + + + + + + void + + void* + + null + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5Fnullptr_5Fvoid_2A_5Fnull.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5Fnullptr_5Fvoid_2A_5Fnull.CSharp.cs new file mode 100644 index 00000000..e2ad5416 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5Fnullptr_5Fvoid_2A_5Fnull.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(void* value = null); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5Fnullptr_5Fvoid_2A_5Fnull.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5Fnullptr_5Fvoid_2A_5Fnull.Xml.xml new file mode 100644 index 00000000..29a1fe64 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/OptionalParameterUnsafeTest_void_20_2A_5Fnullptr_5Fvoid_2A_5Fnull.Xml.xml @@ -0,0 +1,16 @@ + + + + + + void + + void* + + null + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/SourceLocationTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/SourceLocationTest.CSharp.cs new file mode 100644 index 00000000..411ac5af --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/SourceLocationTest.CSharp.cs @@ -0,0 +1,11 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [SourceLocation("ClangUnsavedFile.h", 1, 17)] + public static extern void MyFunction([SourceLocation("ClangUnsavedFile.h", 1, 34)] float value); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/SourceLocationTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/SourceLocationTest.Xml.xml new file mode 100644 index 00000000..a634dd3c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/SourceLocationTest.Xml.xml @@ -0,0 +1,13 @@ + + + + + + void + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateMemberTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateMemberTest.CSharp.cs new file mode 100644 index 00000000..2a6c1392 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateMemberTest.CSharp.cs @@ -0,0 +1,10 @@ +using System; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyTemplate")] + public MyTemplate a; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateMemberTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateMemberTest.Xml.xml new file mode 100644 index 00000000..167460dc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateMemberTest.Xml.xml @@ -0,0 +1,10 @@ + + + + + + MyTemplate<IntPtr> + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_bool_5FTrue_5Fbyte_5F.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_bool_5FTrue_5Fbyte_5F.CSharp.cs new file mode 100644 index 00000000..e4d44b39 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_bool_5FTrue_5Fbyte_5F.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("MyTemplate")] MyTemplate myStruct); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_bool_5FTrue_5Fbyte_5F.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_bool_5FTrue_5Fbyte_5F.Xml.xml new file mode 100644 index 00000000..d13558df --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_bool_5FTrue_5Fbyte_5F.Xml.xml @@ -0,0 +1,13 @@ + + + + + + void + + MyTemplate<byte> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_float_20_2A_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_float_20_2A_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.CSharp.cs new file mode 100644 index 00000000..525bd015 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_float_20_2A_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.CSharp.cs @@ -0,0 +1,11 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("MyTemplate")] MyTemplate myStruct); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_float_20_2A_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_float_20_2A_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.Xml.xml new file mode 100644 index 00000000..01eb189c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_float_20_2A_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.Xml.xml @@ -0,0 +1,13 @@ + + + + + + void + + MyTemplate<IntPtr> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_int_5FFalse_5Fint_5F.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_int_5FFalse_5Fint_5F.CSharp.cs new file mode 100644 index 00000000..15cde60a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_int_5FFalse_5Fint_5F.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(MyTemplate myStruct); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_int_5FFalse_5Fint_5F.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_int_5FFalse_5Fint_5F.Xml.xml new file mode 100644 index 00000000..8624f9b4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_int_5FFalse_5Fint_5F.Xml.xml @@ -0,0 +1,13 @@ + + + + + + void + + MyTemplate<int> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_void_20_28_2A_29_28int_29_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_void_20_28_2A_29_28int_29_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.CSharp.cs new file mode 100644 index 00000000..a312e7e2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_void_20_28_2A_29_28int_29_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.CSharp.cs @@ -0,0 +1,11 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("MyTemplate")] MyTemplate myStruct); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_void_20_28_2A_29_28int_29_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_void_20_28_2A_29_28int_29_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.Xml.xml new file mode 100644 index 00000000..01eb189c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/TemplateParameterTest_void_20_28_2A_29_28int_29_5FTrue_5FIntPtr_5Fusing_20System_3B_0A.Xml.xml @@ -0,0 +1,13 @@ + + + + + + void + + MyTemplate<IntPtr> + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..012e52ec --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Compatible.Windows.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(int value, __arglist); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Default.Windows.cs new file mode 100644 index 00000000..012e52ec --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Default.Windows.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(int value, __arglist); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..012e52ec --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Latest.Windows.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(int value, __arglist); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..012e52ec --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/VarargsTest.CSharp.Preview.Windows.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(int value, __arglist); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarOverrideTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarOverrideTest.CSharp.cs new file mode 100644 index 00000000..92091a8d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarOverrideTest.CSharp.cs @@ -0,0 +1,13 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", ExactSpelling = true)] + public static extern void MyFunction1(int value); + + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.StdCall, ExactSpelling = true)] + public static extern void MyFunction2(int value); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarOverrideTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarOverrideTest.Xml.xml new file mode 100644 index 00000000..4c9c5dd5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarOverrideTest.Xml.xml @@ -0,0 +1,19 @@ + + + + + + void + + int + + + + void + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarTest.CSharp.cs new file mode 100644 index 00000000..85f6e126 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarTest.CSharp.cs @@ -0,0 +1,13 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", ExactSpelling = true)] + public static extern void MyFunction1(int value); + + [DllImport("ClangSharpPInvokeGenerator", ExactSpelling = true)] + public static extern void MyFunction2(int value); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarTest.Xml.xml new file mode 100644 index 00000000..fbb515ff --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvStarTest.Xml.xml @@ -0,0 +1,19 @@ + + + + + + void + + int + + + + void + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvTest.CSharp.cs new file mode 100644 index 00000000..77789cfe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvTest.CSharp.cs @@ -0,0 +1,13 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", ExactSpelling = true)] + public static extern void MyFunction1(int value); + + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction2(int value); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvTest.Xml.xml new file mode 100644 index 00000000..66d23f21 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithCallConvTest.Xml.xml @@ -0,0 +1,19 @@ + + + + + + void + + int + + + + void + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathStarTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathStarTest.CSharp.cs new file mode 100644 index 00000000..e1bfab2e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathStarTest.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathStarTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathStarTest.Xml.xml new file mode 100644 index 00000000..1dfcf83d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathStarTest.Xml.xml @@ -0,0 +1,10 @@ + + + + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathTest.CSharp.cs new file mode 100644 index 00000000..e1bfab2e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathTest.CSharp.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathTest.Xml.xml new file mode 100644 index 00000000..1dfcf83d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithLibraryPathTest.Xml.xml @@ -0,0 +1,10 @@ + + + + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorStarTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorStarTest.CSharp.cs new file mode 100644 index 00000000..72c1144d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorStarTest.CSharp.cs @@ -0,0 +1,13 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] + public static extern void MyFunction1(int value); + + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] + public static extern void MyFunction2(int value); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorStarTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorStarTest.Xml.xml new file mode 100644 index 00000000..ee7e2b73 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorStarTest.Xml.xml @@ -0,0 +1,19 @@ + + + + + + void + + int + + + + void + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorTest.CSharp.cs new file mode 100644 index 00000000..56de16d4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorTest.CSharp.cs @@ -0,0 +1,13 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] + public static extern void MyFunction1(int value); + + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction2(int value); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorTest.Xml.xml new file mode 100644 index 00000000..f25321b1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionDeclarationDllImport/WithSetLastErrorTest.Xml.xml @@ -0,0 +1,19 @@ + + + + + + void + + int + + + + void + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Compatible.cs new file mode 100644 index 00000000..283d4fce --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Compatible.cs @@ -0,0 +1,14 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void Callback(); + + public partial struct MyStruct + { + [NativeTypeName("Callback")] + public IntPtr _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Default.cs new file mode 100644 index 00000000..ab439a0b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Default.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("Callback")] + public delegate* unmanaged[Cdecl] _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Latest.cs new file mode 100644 index 00000000..ab439a0b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Latest.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("Callback")] + public delegate* unmanaged[Cdecl] _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Preview.cs new file mode 100644 index 00000000..ab439a0b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.CSharp.Preview.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("Callback")] + public delegate* unmanaged[Cdecl] _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Compatible.xml new file mode 100644 index 00000000..c7ca8ecc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Compatible.xml @@ -0,0 +1,13 @@ + + + + + void + + + + IntPtr + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Default.xml new file mode 100644 index 00000000..fc11a560 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Default.xml @@ -0,0 +1,10 @@ + + + + + + delegate* unmanaged[Cdecl]<void> + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Latest.xml new file mode 100644 index 00000000..fc11a560 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Latest.xml @@ -0,0 +1,10 @@ + + + + + + delegate* unmanaged[Cdecl]<void> + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Preview.xml new file mode 100644 index 00000000..fc11a560 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/BasicTest.Xml.Preview.xml @@ -0,0 +1,10 @@ + + + + + + delegate* unmanaged[Cdecl]<void> + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Compatible.cs new file mode 100644 index 00000000..63fa8098 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Compatible.cs @@ -0,0 +1,14 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + public delegate void Callback(); + + public partial struct MyStruct + { + [NativeTypeName("Callback")] + public IntPtr _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Default.cs new file mode 100644 index 00000000..e80d15e3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Default.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("Callback")] + public delegate* unmanaged[Stdcall] _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Latest.cs new file mode 100644 index 00000000..e80d15e3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Latest.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("Callback")] + public delegate* unmanaged[Stdcall] _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Preview.cs new file mode 100644 index 00000000..e80d15e3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.CSharp.Preview.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("Callback")] + public delegate* unmanaged[Stdcall] _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Compatible.xml new file mode 100644 index 00000000..e73a7226 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Compatible.xml @@ -0,0 +1,13 @@ + + + + + void + + + + IntPtr + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Default.xml new file mode 100644 index 00000000..8d530d3e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Default.xml @@ -0,0 +1,10 @@ + + + + + + delegate* unmanaged[Stdcall]<void> + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Latest.xml new file mode 100644 index 00000000..8d530d3e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Latest.xml @@ -0,0 +1,10 @@ + + + + + + delegate* unmanaged[Stdcall]<void> + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Preview.xml new file mode 100644 index 00000000..8d530d3e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/CallconvTest.Xml.Preview.xml @@ -0,0 +1,10 @@ + + + + + + delegate* unmanaged[Stdcall]<void> + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Compatible.cs new file mode 100644 index 00000000..0cd46b9d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Compatible.cs @@ -0,0 +1,14 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void Callback(); + + public partial struct MyStruct + { + [NativeTypeName("Callback *")] + public IntPtr _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Default.cs new file mode 100644 index 00000000..9182283e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Default.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("Callback *")] + public delegate* unmanaged[Cdecl] _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Latest.cs new file mode 100644 index 00000000..9182283e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Latest.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("Callback *")] + public delegate* unmanaged[Cdecl] _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Preview.cs new file mode 100644 index 00000000..9182283e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.CSharp.Preview.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("Callback *")] + public delegate* unmanaged[Cdecl] _callback; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Compatible.xml new file mode 100644 index 00000000..ff657d34 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Compatible.xml @@ -0,0 +1,13 @@ + + + + + void + + + + IntPtr + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Default.xml new file mode 100644 index 00000000..3aaad9f6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Default.xml @@ -0,0 +1,10 @@ + + + + + + delegate* unmanaged[Cdecl]<void> + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Latest.xml new file mode 100644 index 00000000..3aaad9f6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Latest.xml @@ -0,0 +1,10 @@ + + + + + + delegate* unmanaged[Cdecl]<void> + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Preview.xml new file mode 100644 index 00000000..3aaad9f6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerDeclaration/PointerlessTypedefTest.Xml.Preview.xml @@ -0,0 +1,10 @@ + + + + + + delegate* unmanaged[Cdecl]<void> + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Compatible.cs new file mode 100644 index 00000000..cbab4c2c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Compatible.cs @@ -0,0 +1,49 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct _MyStruct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C5")] + public _Anonymous_e__Struct Anonymous; + + [NativeTypeName("struct (anonymous struct at ClangUnsavedFile.h:4:5)[2]")] + public _MyArray_e__FixedBuffer MyArray; + + public ref int First + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->First; + } + } + } + + public partial struct _Anonymous_e__Struct + { + public int First; + } + + public partial struct _MyArray_e__Struct + { + public int Second; + } + + public partial struct _MyArray_e__FixedBuffer + { + public _MyArray_e__Struct e0; + public _MyArray_e__Struct e1; + + public unsafe ref _MyArray_e__Struct this[int index] + { + get + { + fixed (_MyArray_e__Struct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Default.cs new file mode 100644 index 00000000..ff857c9f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Default.cs @@ -0,0 +1,39 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct _MyStruct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C5")] + public _Anonymous_e__Struct Anonymous; + + [NativeTypeName("struct (anonymous struct at ClangUnsavedFile.h:4:5)[2]")] + public _MyArray_e__FixedBuffer MyArray; + + [UnscopedRef] + public ref int First + { + get + { + return ref Anonymous.First; + } + } + + public partial struct _Anonymous_e__Struct + { + public int First; + } + + public partial struct _MyArray_e__Struct + { + public int Second; + } + + [InlineArray(2)] + public partial struct _MyArray_e__FixedBuffer + { + public _MyArray_e__Struct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Latest.cs new file mode 100644 index 00000000..ff857c9f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Latest.cs @@ -0,0 +1,39 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct _MyStruct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C5")] + public _Anonymous_e__Struct Anonymous; + + [NativeTypeName("struct (anonymous struct at ClangUnsavedFile.h:4:5)[2]")] + public _MyArray_e__FixedBuffer MyArray; + + [UnscopedRef] + public ref int First + { + get + { + return ref Anonymous.First; + } + } + + public partial struct _Anonymous_e__Struct + { + public int First; + } + + public partial struct _MyArray_e__Struct + { + public int Second; + } + + [InlineArray(2)] + public partial struct _MyArray_e__FixedBuffer + { + public _MyArray_e__Struct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Preview.cs new file mode 100644 index 00000000..ff857c9f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.CSharp.Preview.cs @@ -0,0 +1,39 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct _MyStruct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C5")] + public _Anonymous_e__Struct Anonymous; + + [NativeTypeName("struct (anonymous struct at ClangUnsavedFile.h:4:5)[2]")] + public _MyArray_e__FixedBuffer MyArray; + + [UnscopedRef] + public ref int First + { + get + { + return ref Anonymous.First; + } + } + + public partial struct _Anonymous_e__Struct + { + public int First; + } + + public partial struct _MyArray_e__Struct + { + public int Second; + } + + [InlineArray(2)] + public partial struct _MyArray_e__FixedBuffer + { + public _MyArray_e__Struct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Compatible.xml new file mode 100644 index 00000000..db255f8c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Compatible.xml @@ -0,0 +1,52 @@ + + + + + + _Anonymous_e__Struct + + + _MyArray_e__Struct + + + ref int + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->First; + } + + + + + int + + + + + int + + + + + _MyArray_e__Struct + + + _MyArray_e__Struct + + + ref _MyArray_e__Struct + + int + + + fixed (_MyArray_e__Struct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Default.xml new file mode 100644 index 00000000..4ee4cdc8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Default.xml @@ -0,0 +1,35 @@ + + + + + + _Anonymous_e__Struct + + + _MyArray_e__Struct + + + ref int + + return ref Anonymous.First; + + + + + int + + + + + int + + + + InlineArray(2) + + _MyArray_e__Struct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Latest.xml new file mode 100644 index 00000000..4ee4cdc8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Latest.xml @@ -0,0 +1,35 @@ + + + + + + _Anonymous_e__Struct + + + _MyArray_e__Struct + + + ref int + + return ref Anonymous.First; + + + + + int + + + + + int + + + + InlineArray(2) + + _MyArray_e__Struct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Preview.xml new file mode 100644 index 00000000..4ee4cdc8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/AnonStructAndAnonStructArray.Xml.Preview.xml @@ -0,0 +1,35 @@ + + + + + + _Anonymous_e__Struct + + + _MyArray_e__Struct + + + ref int + + return ref Anonymous.First; + + + + + int + + + + + int + + + + InlineArray(2) + + _MyArray_e__Struct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_double_5Fdouble.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_double_5Fdouble.CSharp.cs new file mode 100644 index 00000000..5ae4f8fe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_double_5Fdouble.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double r; + + public double g; + + public double b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_double_5Fdouble.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_double_5Fdouble.Xml.xml new file mode 100644 index 00000000..5077cd83 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_double_5Fdouble.Xml.xml @@ -0,0 +1,16 @@ + + + + + + double + + + double + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_float_5Ffloat.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_float_5Ffloat.CSharp.cs new file mode 100644 index 00000000..af54b381 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_float_5Ffloat.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float r; + + public float g; + + public float b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_float_5Ffloat.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_float_5Ffloat.Xml.xml new file mode 100644 index 00000000..374ff19a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_float_5Ffloat.Xml.xml @@ -0,0 +1,16 @@ + + + + + + float + + + float + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_int_5Fint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_int_5Fint.CSharp.cs new file mode 100644 index 00000000..30d6c633 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_int_5Fint.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int r; + + public int g; + + public int b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_int_5Fint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_int_5Fint.Xml.xml new file mode 100644 index 00000000..27257476 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_int_5Fint.Xml.xml @@ -0,0 +1,16 @@ + + + + + + int + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_short_5Fshort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_short_5Fshort.CSharp.cs new file mode 100644 index 00000000..eb6aff08 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_short_5Fshort.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short r; + + public short g; + + public short b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_short_5Fshort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_short_5Fshort.Xml.xml new file mode 100644 index 00000000..bbd27e31 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTestInCMode_short_5Fshort.Xml.xml @@ -0,0 +1,16 @@ + + + + + + short + + + short + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_double_5Fdouble.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_double_5Fdouble.CSharp.cs new file mode 100644 index 00000000..5ae4f8fe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_double_5Fdouble.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double r; + + public double g; + + public double b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_double_5Fdouble.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_double_5Fdouble.Xml.xml new file mode 100644 index 00000000..5077cd83 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_double_5Fdouble.Xml.xml @@ -0,0 +1,16 @@ + + + + + + double + + + double + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_float_5Ffloat.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_float_5Ffloat.CSharp.cs new file mode 100644 index 00000000..af54b381 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_float_5Ffloat.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float r; + + public float g; + + public float b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_float_5Ffloat.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_float_5Ffloat.Xml.xml new file mode 100644 index 00000000..374ff19a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_float_5Ffloat.Xml.xml @@ -0,0 +1,16 @@ + + + + + + float + + + float + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_int_5Fint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_int_5Fint.CSharp.cs new file mode 100644 index 00000000..30d6c633 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_int_5Fint.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int r; + + public int g; + + public int b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_int_5Fint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_int_5Fint.Xml.xml new file mode 100644 index 00000000..27257476 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_int_5Fint.Xml.xml @@ -0,0 +1,16 @@ + + + + + + int + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_short_5Fshort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_short_5Fshort.CSharp.cs new file mode 100644 index 00000000..eb6aff08 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_short_5Fshort.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short r; + + public short g; + + public short b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_short_5Fshort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_short_5Fshort.Xml.xml new file mode 100644 index 00000000..bbd27e31 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicTest_short_5Fshort.Xml.xml @@ -0,0 +1,16 @@ + + + + + + short + + + short + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs new file mode 100644 index 00000000..2459a799 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("bool")] + public byte r; + + [NativeTypeName("bool")] + public byte g; + + [NativeTypeName("bool")] + public byte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.Xml.xml new file mode 100644 index 00000000..2efd5005 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + byte + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs new file mode 100644 index 00000000..b7fe72ca --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("long long")] + public long r; + + [NativeTypeName("long long")] + public long g; + + [NativeTypeName("long long")] + public long b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.Xml.xml new file mode 100644 index 00000000..510adc82 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.Xml.xml @@ -0,0 +1,16 @@ + + + + + + long + + + long + + + long + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs new file mode 100644 index 00000000..76c52d3c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("signed char")] + public sbyte r; + + [NativeTypeName("signed char")] + public sbyte g; + + [NativeTypeName("signed char")] + public sbyte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml new file mode 100644 index 00000000..ef4a07bf --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + sbyte + + + sbyte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs new file mode 100644 index 00000000..efea8ec7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned char")] + public byte r; + + [NativeTypeName("unsigned char")] + public byte g; + + [NativeTypeName("unsigned char")] + public byte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml new file mode 100644 index 00000000..9dbe4132 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + byte + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs new file mode 100644 index 00000000..6bced97f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned int")] + public uint r; + + [NativeTypeName("unsigned int")] + public uint g; + + [NativeTypeName("unsigned int")] + public uint b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml new file mode 100644 index 00000000..0e7bdb22 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + uint + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs new file mode 100644 index 00000000..4b6da458 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned long long")] + public ulong r; + + [NativeTypeName("unsigned long long")] + public ulong g; + + [NativeTypeName("unsigned long long")] + public ulong b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml new file mode 100644 index 00000000..e8cfdc96 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + ulong + + + ulong + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs new file mode 100644 index 00000000..91e4bec0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned short")] + public ushort r; + + [NativeTypeName("unsigned short")] + public ushort g; + + [NativeTypeName("unsigned short")] + public ushort b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml new file mode 100644 index 00000000..207d533d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + ushort + + + ushort + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..a8033504 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,177 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + get + { + return (byte)((_bitfield2 >> 22) & 0x1u); + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + } + } + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + get + { + return (int)(_bitfield2 << 8) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + get + { + return (int)(_bitfield2 << 7) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + } + } + } + + public partial struct MyStruct2 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..52382789 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Compatible.Windows.cs @@ -0,0 +1,181 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + public byte _bitfield3; + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + get + { + return (byte)(_bitfield3 & 0x1u); + } + + set + { + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + } + } + + public int _bitfield4; + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + get + { + return (_bitfield4 << 31) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + get + { + return (_bitfield4 << 30) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + } + } + } + + public partial struct MyStruct2 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..fc22731b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Default.Unix.cs @@ -0,0 +1,177 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)((_bitfield2 >> 22) & 0x1u); + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + } + } + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (int)(_bitfield2 << 8) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (int)(_bitfield2 << 7) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + } + } + } + + public partial struct MyStruct2 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Default.Windows.cs new file mode 100644 index 00000000..358bba3a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Default.Windows.cs @@ -0,0 +1,181 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + public byte _bitfield3; + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)(_bitfield3 & 0x1u); + } + + set + { + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + } + } + + public int _bitfield4; + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (_bitfield4 << 31) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (_bitfield4 << 30) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + } + } + } + + public partial struct MyStruct2 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..fc22731b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Latest.Unix.cs @@ -0,0 +1,177 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)((_bitfield2 >> 22) & 0x1u); + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + } + } + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (int)(_bitfield2 << 8) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (int)(_bitfield2 << 7) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + } + } + } + + public partial struct MyStruct2 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..358bba3a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Latest.Windows.cs @@ -0,0 +1,181 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + public byte _bitfield3; + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)(_bitfield3 & 0x1u); + } + + set + { + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + } + } + + public int _bitfield4; + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (_bitfield4 << 31) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (_bitfield4 << 30) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + } + } + } + + public partial struct MyStruct2 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..fc22731b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Preview.Unix.cs @@ -0,0 +1,177 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)((_bitfield2 >> 22) & 0x1u); + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + } + } + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (int)(_bitfield2 << 8) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (int)(_bitfield2 << 7) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + } + } + } + + public partial struct MyStruct2 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..358bba3a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.CSharp.Preview.Windows.cs @@ -0,0 +1,181 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + public byte _bitfield3; + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)(_bitfield3 & 0x1u); + } + + set + { + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + } + } + + public int _bitfield4; + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (_bitfield4 << 31) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (_bitfield4 << 30) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + } + } + } + + public partial struct MyStruct2 + { + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..e262a062 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Compatible.Unix.xml @@ -0,0 +1,139 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + return (byte)((_bitfield2 >> 22) & 0x1u); + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + + + + int + + return (int)(_bitfield2 << 8) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + + + + int + + return (int)(_bitfield2 << 7) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Compatible.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Compatible.Windows.xml new file mode 100644 index 00000000..e2c314cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Compatible.Windows.xml @@ -0,0 +1,145 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + + byte + + return (byte)(_bitfield3 & 0x1u); + + + + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + + + + int + + + int + + return (_bitfield4 << 31) >> 31; + + + + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + + + + int + + return (_bitfield4 << 30) >> 31; + + + + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..e262a062 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Default.Unix.xml @@ -0,0 +1,139 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + return (byte)((_bitfield2 >> 22) & 0x1u); + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + + + + int + + return (int)(_bitfield2 << 8) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + + + + int + + return (int)(_bitfield2 << 7) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Default.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Default.Windows.xml new file mode 100644 index 00000000..e2c314cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Default.Windows.xml @@ -0,0 +1,145 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + + byte + + return (byte)(_bitfield3 & 0x1u); + + + + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + + + + int + + + int + + return (_bitfield4 << 31) >> 31; + + + + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + + + + int + + return (_bitfield4 << 30) >> 31; + + + + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..e262a062 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Latest.Unix.xml @@ -0,0 +1,139 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + return (byte)((_bitfield2 >> 22) & 0x1u); + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + + + + int + + return (int)(_bitfield2 << 8) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + + + + int + + return (int)(_bitfield2 << 7) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Latest.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Latest.Windows.xml new file mode 100644 index 00000000..e2c314cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Latest.Windows.xml @@ -0,0 +1,145 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + + byte + + return (byte)(_bitfield3 & 0x1u); + + + + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + + + + int + + + int + + return (_bitfield4 << 31) >> 31; + + + + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + + + + int + + return (_bitfield4 << 30) >> 31; + + + + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..e262a062 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Preview.Unix.xml @@ -0,0 +1,139 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + return (byte)((_bitfield2 >> 22) & 0x1u); + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + + + + int + + return (int)(_bitfield2 << 8) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + + + + int + + return (int)(_bitfield2 << 7) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Preview.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Preview.Windows.xml new file mode 100644 index 00000000..e2c314cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldTest.Xml.Preview.Windows.xml @@ -0,0 +1,145 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + + byte + + return (byte)(_bitfield3 & 0x1u); + + + + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + + + + int + + + int + + return (_bitfield4 << 31) >> 31; + + + + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + + + + int + + return (_bitfield4 << 30) >> 31; + + + + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..f4f0ba82 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,188 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + [NativeBitfield("o0_b0_24", offset: 0, length: 24)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [NativeBitfield("o4_b0_16", offset: 0, length: 16)] + [NativeBitfield("o4_b16_3", offset: 16, length: 3)] + [NativeBitfield("o4_b19_3", offset: 19, length: 3)] + [NativeBitfield("o8_b0_1", offset: 22, length: 1)] + [NativeBitfield("o12_b0_1", offset: 23, length: 1)] + [NativeBitfield("o12_b1_1", offset: 24, length: 1)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + get + { + return (byte)((_bitfield2 >> 22) & 0x1u); + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + } + } + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + get + { + return (int)(_bitfield2 << 8) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + get + { + return (int)(_bitfield2 << 7) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + } + } + } + + public partial struct MyStruct2 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + [NativeBitfield("o8_b0_1", offset: 0, length: 1)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + [NativeBitfield("o0_b1_1", offset: 1, length: 1)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..19f379ac --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Compatible.Windows.cs @@ -0,0 +1,192 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + [NativeBitfield("o0_b0_24", offset: 0, length: 24)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [NativeBitfield("o4_b0_16", offset: 0, length: 16)] + [NativeBitfield("o4_b16_3", offset: 16, length: 3)] + [NativeBitfield("o4_b19_3", offset: 19, length: 3)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeBitfield("o8_b0_1", offset: 0, length: 1)] + public byte _bitfield3; + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + get + { + return (byte)(_bitfield3 & 0x1u); + } + + set + { + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + } + } + + [NativeBitfield("o12_b0_1", offset: 0, length: 1)] + [NativeBitfield("o12_b1_1", offset: 1, length: 1)] + public int _bitfield4; + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + get + { + return (_bitfield4 << 31) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + get + { + return (_bitfield4 << 30) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + } + } + } + + public partial struct MyStruct2 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + [NativeBitfield("o8_b0_1", offset: 0, length: 1)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + [NativeBitfield("o0_b1_1", offset: 1, length: 1)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..7f116697 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Default.Unix.cs @@ -0,0 +1,188 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + [NativeBitfield("o0_b0_24", offset: 0, length: 24)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [NativeBitfield("o4_b0_16", offset: 0, length: 16)] + [NativeBitfield("o4_b16_3", offset: 16, length: 3)] + [NativeBitfield("o4_b19_3", offset: 19, length: 3)] + [NativeBitfield("o8_b0_1", offset: 22, length: 1)] + [NativeBitfield("o12_b0_1", offset: 23, length: 1)] + [NativeBitfield("o12_b1_1", offset: 24, length: 1)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)((_bitfield2 >> 22) & 0x1u); + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + } + } + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (int)(_bitfield2 << 8) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (int)(_bitfield2 << 7) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + } + } + } + + public partial struct MyStruct2 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + [NativeBitfield("o8_b0_1", offset: 0, length: 1)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + [NativeBitfield("o0_b1_1", offset: 1, length: 1)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Default.Windows.cs new file mode 100644 index 00000000..1efd47ae --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Default.Windows.cs @@ -0,0 +1,192 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + [NativeBitfield("o0_b0_24", offset: 0, length: 24)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [NativeBitfield("o4_b0_16", offset: 0, length: 16)] + [NativeBitfield("o4_b16_3", offset: 16, length: 3)] + [NativeBitfield("o4_b19_3", offset: 19, length: 3)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeBitfield("o8_b0_1", offset: 0, length: 1)] + public byte _bitfield3; + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)(_bitfield3 & 0x1u); + } + + set + { + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + } + } + + [NativeBitfield("o12_b0_1", offset: 0, length: 1)] + [NativeBitfield("o12_b1_1", offset: 1, length: 1)] + public int _bitfield4; + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (_bitfield4 << 31) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (_bitfield4 << 30) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + } + } + } + + public partial struct MyStruct2 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + [NativeBitfield("o8_b0_1", offset: 0, length: 1)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + [NativeBitfield("o0_b1_1", offset: 1, length: 1)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..7f116697 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Latest.Unix.cs @@ -0,0 +1,188 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + [NativeBitfield("o0_b0_24", offset: 0, length: 24)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [NativeBitfield("o4_b0_16", offset: 0, length: 16)] + [NativeBitfield("o4_b16_3", offset: 16, length: 3)] + [NativeBitfield("o4_b19_3", offset: 19, length: 3)] + [NativeBitfield("o8_b0_1", offset: 22, length: 1)] + [NativeBitfield("o12_b0_1", offset: 23, length: 1)] + [NativeBitfield("o12_b1_1", offset: 24, length: 1)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)((_bitfield2 >> 22) & 0x1u); + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + } + } + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (int)(_bitfield2 << 8) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (int)(_bitfield2 << 7) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + } + } + } + + public partial struct MyStruct2 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + [NativeBitfield("o8_b0_1", offset: 0, length: 1)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + [NativeBitfield("o0_b1_1", offset: 1, length: 1)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..1efd47ae --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Latest.Windows.cs @@ -0,0 +1,192 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + [NativeBitfield("o0_b0_24", offset: 0, length: 24)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [NativeBitfield("o4_b0_16", offset: 0, length: 16)] + [NativeBitfield("o4_b16_3", offset: 16, length: 3)] + [NativeBitfield("o4_b19_3", offset: 19, length: 3)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeBitfield("o8_b0_1", offset: 0, length: 1)] + public byte _bitfield3; + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)(_bitfield3 & 0x1u); + } + + set + { + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + } + } + + [NativeBitfield("o12_b0_1", offset: 0, length: 1)] + [NativeBitfield("o12_b1_1", offset: 1, length: 1)] + public int _bitfield4; + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (_bitfield4 << 31) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (_bitfield4 << 30) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + } + } + } + + public partial struct MyStruct2 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + [NativeBitfield("o8_b0_1", offset: 0, length: 1)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + [NativeBitfield("o0_b1_1", offset: 1, length: 1)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..7f116697 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Preview.Unix.cs @@ -0,0 +1,188 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + [NativeBitfield("o0_b0_24", offset: 0, length: 24)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [NativeBitfield("o4_b0_16", offset: 0, length: 16)] + [NativeBitfield("o4_b16_3", offset: 16, length: 3)] + [NativeBitfield("o4_b19_3", offset: 19, length: 3)] + [NativeBitfield("o8_b0_1", offset: 22, length: 1)] + [NativeBitfield("o12_b0_1", offset: 23, length: 1)] + [NativeBitfield("o12_b1_1", offset: 24, length: 1)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)((_bitfield2 >> 22) & 0x1u); + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + } + } + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (int)(_bitfield2 << 8) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (int)(_bitfield2 << 7) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + } + } + } + + public partial struct MyStruct2 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + [NativeBitfield("o8_b0_1", offset: 0, length: 1)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + [NativeBitfield("o0_b1_1", offset: 1, length: 1)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..1efd47ae --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.CSharp.Preview.Windows.cs @@ -0,0 +1,192 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1 + { + [NativeBitfield("o0_b0_24", offset: 0, length: 24)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [NativeBitfield("o4_b0_16", offset: 0, length: 16)] + [NativeBitfield("o4_b16_3", offset: 16, length: 3)] + [NativeBitfield("o4_b19_3", offset: 19, length: 3)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeBitfield("o8_b0_1", offset: 0, length: 1)] + public byte _bitfield3; + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)(_bitfield3 & 0x1u); + } + + set + { + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + } + } + + [NativeBitfield("o12_b0_1", offset: 0, length: 1)] + [NativeBitfield("o12_b1_1", offset: 1, length: 1)] + public int _bitfield4; + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (_bitfield4 << 31) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (_bitfield4 << 30) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + } + } + } + + public partial struct MyStruct2 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + public int x; + + [NativeBitfield("o8_b0_1", offset: 0, length: 1)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + public partial struct MyStruct3 + { + [NativeBitfield("o0_b0_1", offset: 0, length: 1)] + [NativeBitfield("o0_b1_1", offset: 1, length: 1)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..683d5071 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Compatible.Unix.xml @@ -0,0 +1,150 @@ + + + + + + NativeBitfield("o0_b0_24", offset: 0, length: 24) + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + NativeBitfield("o4_b0_16", offset: 0, length: 16) + NativeBitfield("o4_b16_3", offset: 16, length: 3) + NativeBitfield("o4_b19_3", offset: 19, length: 3) + NativeBitfield("o8_b0_1", offset: 22, length: 1) + NativeBitfield("o12_b0_1", offset: 23, length: 1) + NativeBitfield("o12_b1_1", offset: 24, length: 1) + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + return (byte)((_bitfield2 >> 22) & 0x1u); + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + + + + int + + return (int)(_bitfield2 << 8) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + + + + int + + return (int)(_bitfield2 << 7) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + NativeBitfield("o8_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + NativeBitfield("o0_b1_1", offset: 1, length: 1) + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Compatible.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Compatible.Windows.xml new file mode 100644 index 00000000..dceb05b7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Compatible.Windows.xml @@ -0,0 +1,156 @@ + + + + + + NativeBitfield("o0_b0_24", offset: 0, length: 24) + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + NativeBitfield("o4_b0_16", offset: 0, length: 16) + NativeBitfield("o4_b16_3", offset: 16, length: 3) + NativeBitfield("o4_b19_3", offset: 19, length: 3) + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + NativeBitfield("o8_b0_1", offset: 0, length: 1) + byte + + + byte + + return (byte)(_bitfield3 & 0x1u); + + + + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + + + + NativeBitfield("o12_b0_1", offset: 0, length: 1) + NativeBitfield("o12_b1_1", offset: 1, length: 1) + int + + + int + + return (_bitfield4 << 31) >> 31; + + + + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + + + + int + + return (_bitfield4 << 30) >> 31; + + + + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + NativeBitfield("o8_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + NativeBitfield("o0_b1_1", offset: 1, length: 1) + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..683d5071 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Default.Unix.xml @@ -0,0 +1,150 @@ + + + + + + NativeBitfield("o0_b0_24", offset: 0, length: 24) + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + NativeBitfield("o4_b0_16", offset: 0, length: 16) + NativeBitfield("o4_b16_3", offset: 16, length: 3) + NativeBitfield("o4_b19_3", offset: 19, length: 3) + NativeBitfield("o8_b0_1", offset: 22, length: 1) + NativeBitfield("o12_b0_1", offset: 23, length: 1) + NativeBitfield("o12_b1_1", offset: 24, length: 1) + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + return (byte)((_bitfield2 >> 22) & 0x1u); + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + + + + int + + return (int)(_bitfield2 << 8) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + + + + int + + return (int)(_bitfield2 << 7) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + NativeBitfield("o8_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + NativeBitfield("o0_b1_1", offset: 1, length: 1) + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Default.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Default.Windows.xml new file mode 100644 index 00000000..dceb05b7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Default.Windows.xml @@ -0,0 +1,156 @@ + + + + + + NativeBitfield("o0_b0_24", offset: 0, length: 24) + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + NativeBitfield("o4_b0_16", offset: 0, length: 16) + NativeBitfield("o4_b16_3", offset: 16, length: 3) + NativeBitfield("o4_b19_3", offset: 19, length: 3) + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + NativeBitfield("o8_b0_1", offset: 0, length: 1) + byte + + + byte + + return (byte)(_bitfield3 & 0x1u); + + + + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + + + + NativeBitfield("o12_b0_1", offset: 0, length: 1) + NativeBitfield("o12_b1_1", offset: 1, length: 1) + int + + + int + + return (_bitfield4 << 31) >> 31; + + + + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + + + + int + + return (_bitfield4 << 30) >> 31; + + + + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + NativeBitfield("o8_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + NativeBitfield("o0_b1_1", offset: 1, length: 1) + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..683d5071 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Latest.Unix.xml @@ -0,0 +1,150 @@ + + + + + + NativeBitfield("o0_b0_24", offset: 0, length: 24) + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + NativeBitfield("o4_b0_16", offset: 0, length: 16) + NativeBitfield("o4_b16_3", offset: 16, length: 3) + NativeBitfield("o4_b19_3", offset: 19, length: 3) + NativeBitfield("o8_b0_1", offset: 22, length: 1) + NativeBitfield("o12_b0_1", offset: 23, length: 1) + NativeBitfield("o12_b1_1", offset: 24, length: 1) + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + return (byte)((_bitfield2 >> 22) & 0x1u); + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + + + + int + + return (int)(_bitfield2 << 8) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + + + + int + + return (int)(_bitfield2 << 7) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + NativeBitfield("o8_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + NativeBitfield("o0_b1_1", offset: 1, length: 1) + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Latest.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Latest.Windows.xml new file mode 100644 index 00000000..dceb05b7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Latest.Windows.xml @@ -0,0 +1,156 @@ + + + + + + NativeBitfield("o0_b0_24", offset: 0, length: 24) + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + NativeBitfield("o4_b0_16", offset: 0, length: 16) + NativeBitfield("o4_b16_3", offset: 16, length: 3) + NativeBitfield("o4_b19_3", offset: 19, length: 3) + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + NativeBitfield("o8_b0_1", offset: 0, length: 1) + byte + + + byte + + return (byte)(_bitfield3 & 0x1u); + + + + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + + + + NativeBitfield("o12_b0_1", offset: 0, length: 1) + NativeBitfield("o12_b1_1", offset: 1, length: 1) + int + + + int + + return (_bitfield4 << 31) >> 31; + + + + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + + + + int + + return (_bitfield4 << 30) >> 31; + + + + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + NativeBitfield("o8_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + NativeBitfield("o0_b1_1", offset: 1, length: 1) + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..683d5071 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Preview.Unix.xml @@ -0,0 +1,150 @@ + + + + + + NativeBitfield("o0_b0_24", offset: 0, length: 24) + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + NativeBitfield("o4_b0_16", offset: 0, length: 16) + NativeBitfield("o4_b16_3", offset: 16, length: 3) + NativeBitfield("o4_b19_3", offset: 19, length: 3) + NativeBitfield("o8_b0_1", offset: 22, length: 1) + NativeBitfield("o12_b0_1", offset: 23, length: 1) + NativeBitfield("o12_b1_1", offset: 24, length: 1) + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + return (byte)((_bitfield2 >> 22) & 0x1u); + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + + + + int + + return (int)(_bitfield2 << 8) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + + + + int + + return (int)(_bitfield2 << 7) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + NativeBitfield("o8_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + NativeBitfield("o0_b1_1", offset: 1, length: 1) + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Preview.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Preview.Windows.xml new file mode 100644 index 00000000..dceb05b7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/BitfieldWithNativeBitfieldAttributeTest.Xml.Preview.Windows.xml @@ -0,0 +1,156 @@ + + + + + + NativeBitfield("o0_b0_24", offset: 0, length: 24) + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + NativeBitfield("o4_b0_16", offset: 0, length: 16) + NativeBitfield("o4_b16_3", offset: 16, length: 3) + NativeBitfield("o4_b19_3", offset: 19, length: 3) + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + NativeBitfield("o8_b0_1", offset: 0, length: 1) + byte + + + byte + + return (byte)(_bitfield3 & 0x1u); + + + + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + + + + NativeBitfield("o12_b0_1", offset: 0, length: 1) + NativeBitfield("o12_b1_1", offset: 1, length: 1) + int + + + int + + return (_bitfield4 << 31) >> 31; + + + + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + + + + int + + return (_bitfield4 << 30) >> 31; + + + + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + NativeBitfield("o8_b0_1", offset: 0, length: 1) + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + NativeBitfield("o0_b0_1", offset: 0, length: 1) + NativeBitfield("o0_b1_1", offset: 1, length: 1) + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Compatible.cs new file mode 100644 index 00000000..19d8a073 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Compatible.cs @@ -0,0 +1,17 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("decltype(&MyFunction)")] + public IntPtr _callback; + } + + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Default.cs new file mode 100644 index 00000000..bf5296e7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("decltype(&MyFunction)")] + public delegate* unmanaged[Cdecl] _callback; + } + + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Latest.cs new file mode 100644 index 00000000..bf5296e7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("decltype(&MyFunction)")] + public delegate* unmanaged[Cdecl] _callback; + } + + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Preview.cs new file mode 100644 index 00000000..bf5296e7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("decltype(&MyFunction)")] + public delegate* unmanaged[Cdecl] _callback; + } + + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Compatible.xml new file mode 100644 index 00000000..dc4426bb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Compatible.xml @@ -0,0 +1,15 @@ + + + + + + IntPtr + + + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Default.xml new file mode 100644 index 00000000..c01c221f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Default.xml @@ -0,0 +1,15 @@ + + + + + + delegate* unmanaged[Cdecl]<void> + + + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Latest.xml new file mode 100644 index 00000000..c01c221f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Latest.xml @@ -0,0 +1,15 @@ + + + + + + delegate* unmanaged[Cdecl]<void> + + + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Preview.xml new file mode 100644 index 00000000..c01c221f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeclTypeTest.Xml.Preview.xml @@ -0,0 +1,15 @@ + + + + + + delegate* unmanaged[Cdecl]<void> + + + + + void + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Compatible.cs new file mode 100644 index 00000000..ed141de7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Compatible.cs @@ -0,0 +1,55 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct _MyStruct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C5")] + public _Anonymous_e__Struct Anonymous; + + public ref int Value1 + { + get + { + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous2_e__Struct* pField = &Anonymous.Anonymous1.Anonymous2) + { + return ref pField->Value1; + } + } + } + + public ref int Value2 + { + get + { + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous3_e__Struct* pField = &Anonymous.Anonymous1.Anonymous3) + { + return ref pField->Value2; + } + } + } + + public unsafe partial struct _Anonymous_e__Struct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C14")] + public _Anonymous1_e__Struct Anonymous1; + + public unsafe partial struct _Anonymous1_e__Struct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L4_C9")] + public _Anonymous2_e__Struct Anonymous2; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L5_C9")] + public _Anonymous3_e__Struct Anonymous3; + + public partial struct _Anonymous2_e__Struct + { + public int Value1; + } + + public partial struct _Anonymous3_e__Struct + { + public int Value2; + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Default.cs new file mode 100644 index 00000000..8d02c608 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Default.cs @@ -0,0 +1,53 @@ +using System.Diagnostics.CodeAnalysis; + +namespace ClangSharp.Test +{ + public partial struct _MyStruct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int Value1 + { + get + { + return ref Anonymous.Anonymous1.Anonymous2.Value1; + } + } + + [UnscopedRef] + public ref int Value2 + { + get + { + return ref Anonymous.Anonymous1.Anonymous3.Value2; + } + } + + public partial struct _Anonymous_e__Struct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C14")] + public _Anonymous1_e__Struct Anonymous1; + + public partial struct _Anonymous1_e__Struct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L4_C9")] + public _Anonymous2_e__Struct Anonymous2; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L5_C9")] + public _Anonymous3_e__Struct Anonymous3; + + public partial struct _Anonymous2_e__Struct + { + public int Value1; + } + + public partial struct _Anonymous3_e__Struct + { + public int Value2; + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Latest.cs new file mode 100644 index 00000000..8d02c608 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Latest.cs @@ -0,0 +1,53 @@ +using System.Diagnostics.CodeAnalysis; + +namespace ClangSharp.Test +{ + public partial struct _MyStruct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int Value1 + { + get + { + return ref Anonymous.Anonymous1.Anonymous2.Value1; + } + } + + [UnscopedRef] + public ref int Value2 + { + get + { + return ref Anonymous.Anonymous1.Anonymous3.Value2; + } + } + + public partial struct _Anonymous_e__Struct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C14")] + public _Anonymous1_e__Struct Anonymous1; + + public partial struct _Anonymous1_e__Struct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L4_C9")] + public _Anonymous2_e__Struct Anonymous2; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L5_C9")] + public _Anonymous3_e__Struct Anonymous3; + + public partial struct _Anonymous2_e__Struct + { + public int Value1; + } + + public partial struct _Anonymous3_e__Struct + { + public int Value2; + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Preview.cs new file mode 100644 index 00000000..8d02c608 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.CSharp.Preview.cs @@ -0,0 +1,53 @@ +using System.Diagnostics.CodeAnalysis; + +namespace ClangSharp.Test +{ + public partial struct _MyStruct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int Value1 + { + get + { + return ref Anonymous.Anonymous1.Anonymous2.Value1; + } + } + + [UnscopedRef] + public ref int Value2 + { + get + { + return ref Anonymous.Anonymous1.Anonymous3.Value2; + } + } + + public partial struct _Anonymous_e__Struct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L3_C14")] + public _Anonymous1_e__Struct Anonymous1; + + public partial struct _Anonymous1_e__Struct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L4_C9")] + public _Anonymous2_e__Struct Anonymous2; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L5_C9")] + public _Anonymous3_e__Struct Anonymous3; + + public partial struct _Anonymous2_e__Struct + { + public int Value1; + } + + public partial struct _Anonymous3_e__Struct + { + public int Value2; + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Compatible.xml new file mode 100644 index 00000000..53112226 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Compatible.xml @@ -0,0 +1,51 @@ + + + + + + _Anonymous_e__Struct + + + ref int + + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous2_e__Struct* pField = &Anonymous.Anonymous1.Anonymous2) + { + return ref pField->Value1; + } + + + + ref int + + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous3_e__Struct* pField = &Anonymous.Anonymous1.Anonymous3) + { + return ref pField->Value2; + } + + + + + _Anonymous1_e__Struct + + + + _Anonymous2_e__Struct + + + _Anonymous3_e__Struct + + + + int + + + + + int + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Default.xml new file mode 100644 index 00000000..9f13feb6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Default.xml @@ -0,0 +1,45 @@ + + + + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.Anonymous1.Anonymous2.Value1; + + + + ref int + + return ref Anonymous.Anonymous1.Anonymous3.Value2; + + + + + _Anonymous1_e__Struct + + + + _Anonymous2_e__Struct + + + _Anonymous3_e__Struct + + + + int + + + + + int + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Latest.xml new file mode 100644 index 00000000..9f13feb6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Latest.xml @@ -0,0 +1,45 @@ + + + + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.Anonymous1.Anonymous2.Value1; + + + + ref int + + return ref Anonymous.Anonymous1.Anonymous3.Value2; + + + + + _Anonymous1_e__Struct + + + + _Anonymous2_e__Struct + + + _Anonymous3_e__Struct + + + + int + + + + + int + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Preview.xml new file mode 100644 index 00000000..9f13feb6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/DeeplyNestedAnonStructs.Xml.Preview.xml @@ -0,0 +1,45 @@ + + + + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.Anonymous1.Anonymous2.Value1; + + + + ref int + + return ref Anonymous.Anonymous1.Anonymous3.Value2; + + + + + _Anonymous1_e__Struct + + + + _Anonymous2_e__Struct + + + _Anonymous3_e__Struct + + + + int + + + + + int + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/ExcludeTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/ExcludeTest.CSharp.cs new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/ExcludeTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/ExcludeTest.Xml.xml new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs new file mode 100644 index 00000000..73670d4f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs @@ -0,0 +1,63 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + public MyStruct e1_0_0_0; + + public MyStruct e0_0_1_0; + public MyStruct e1_0_1_0; + + public MyStruct e0_0_2_0; + public MyStruct e1_0_2_0; + + public MyStruct e0_0_0_1; + public MyStruct e1_0_0_1; + + public MyStruct e0_0_1_1; + public MyStruct e1_0_1_1; + + public MyStruct e0_0_2_1; + public MyStruct e1_0_2_1; + + public MyStruct e0_0_0_2; + public MyStruct e1_0_0_2; + + public MyStruct e0_0_1_2; + public MyStruct e1_0_1_2; + + public MyStruct e0_0_2_2; + public MyStruct e1_0_2_2; + + public MyStruct e0_0_0_3; + public MyStruct e1_0_0_3; + + public MyStruct e0_0_1_3; + public MyStruct e1_0_1_3; + + public MyStruct e0_0_2_3; + public MyStruct e1_0_2_3; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs new file mode 100644 index 00000000..0cadd4e3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs new file mode 100644 index 00000000..0cadd4e3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs new file mode 100644 index 00000000..0cadd4e3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml new file mode 100644 index 00000000..8d6c9664 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml @@ -0,0 +1,101 @@ + + + + + + double + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml new file mode 100644 index 00000000..edd1a3dc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyStruct + + + InlineArray(2 * 1 * 3 * 4) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml new file mode 100644 index 00000000..edd1a3dc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyStruct + + + InlineArray(2 * 1 * 3 * 4) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml new file mode 100644 index 00000000..edd1a3dc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyStruct + + + InlineArray(2 * 1 * 3 * 4) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs new file mode 100644 index 00000000..589ea7f0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs @@ -0,0 +1,63 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + public MyStruct e1_0_0_0; + + public MyStruct e0_0_1_0; + public MyStruct e1_0_1_0; + + public MyStruct e0_0_2_0; + public MyStruct e1_0_2_0; + + public MyStruct e0_0_0_1; + public MyStruct e1_0_0_1; + + public MyStruct e0_0_1_1; + public MyStruct e1_0_1_1; + + public MyStruct e0_0_2_1; + public MyStruct e1_0_2_1; + + public MyStruct e0_0_0_2; + public MyStruct e1_0_0_2; + + public MyStruct e0_0_1_2; + public MyStruct e1_0_1_2; + + public MyStruct e0_0_2_2; + public MyStruct e1_0_2_2; + + public MyStruct e0_0_0_3; + public MyStruct e1_0_0_3; + + public MyStruct e0_0_1_3; + public MyStruct e1_0_1_3; + + public MyStruct e0_0_2_3; + public MyStruct e1_0_2_3; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs new file mode 100644 index 00000000..e8ca9097 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs new file mode 100644 index 00000000..e8ca9097 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs new file mode 100644 index 00000000..e8ca9097 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml new file mode 100644 index 00000000..97260c53 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml @@ -0,0 +1,101 @@ + + + + + + float + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml new file mode 100644 index 00000000..4ab86ff3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyStruct + + + InlineArray(2 * 1 * 3 * 4) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml new file mode 100644 index 00000000..4ab86ff3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyStruct + + + InlineArray(2 * 1 * 3 * 4) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml new file mode 100644 index 00000000..4ab86ff3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyStruct + + + InlineArray(2 * 1 * 3 * 4) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs new file mode 100644 index 00000000..7b4d3408 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs @@ -0,0 +1,63 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + public MyStruct e1_0_0_0; + + public MyStruct e0_0_1_0; + public MyStruct e1_0_1_0; + + public MyStruct e0_0_2_0; + public MyStruct e1_0_2_0; + + public MyStruct e0_0_0_1; + public MyStruct e1_0_0_1; + + public MyStruct e0_0_1_1; + public MyStruct e1_0_1_1; + + public MyStruct e0_0_2_1; + public MyStruct e1_0_2_1; + + public MyStruct e0_0_0_2; + public MyStruct e1_0_0_2; + + public MyStruct e0_0_1_2; + public MyStruct e1_0_1_2; + + public MyStruct e0_0_2_2; + public MyStruct e1_0_2_2; + + public MyStruct e0_0_0_3; + public MyStruct e1_0_0_3; + + public MyStruct e0_0_1_3; + public MyStruct e1_0_1_3; + + public MyStruct e0_0_2_3; + public MyStruct e1_0_2_3; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs new file mode 100644 index 00000000..d3a731c1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs new file mode 100644 index 00000000..d3a731c1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs new file mode 100644 index 00000000..d3a731c1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml new file mode 100644 index 00000000..19707ab0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml @@ -0,0 +1,101 @@ + + + + + + int + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml new file mode 100644 index 00000000..9a97ac1f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyStruct + + + InlineArray(2 * 1 * 3 * 4) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml new file mode 100644 index 00000000..9a97ac1f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyStruct + + + InlineArray(2 * 1 * 3 * 4) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml new file mode 100644 index 00000000..9a97ac1f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyStruct + + + InlineArray(2 * 1 * 3 * 4) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs new file mode 100644 index 00000000..120dc040 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs @@ -0,0 +1,63 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + public MyStruct e1_0_0_0; + + public MyStruct e0_0_1_0; + public MyStruct e1_0_1_0; + + public MyStruct e0_0_2_0; + public MyStruct e1_0_2_0; + + public MyStruct e0_0_0_1; + public MyStruct e1_0_0_1; + + public MyStruct e0_0_1_1; + public MyStruct e1_0_1_1; + + public MyStruct e0_0_2_1; + public MyStruct e1_0_2_1; + + public MyStruct e0_0_0_2; + public MyStruct e1_0_0_2; + + public MyStruct e0_0_1_2; + public MyStruct e1_0_1_2; + + public MyStruct e0_0_2_2; + public MyStruct e1_0_2_2; + + public MyStruct e0_0_0_3; + public MyStruct e1_0_0_3; + + public MyStruct e0_0_1_3; + public MyStruct e1_0_1_3; + + public MyStruct e0_0_2_3; + public MyStruct e1_0_2_3; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs new file mode 100644 index 00000000..9391a32c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs new file mode 100644 index 00000000..9391a32c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs new file mode 100644 index 00000000..9391a32c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml new file mode 100644 index 00000000..a2ec9330 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml @@ -0,0 +1,101 @@ + + + + + + short + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml new file mode 100644 index 00000000..49d01557 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyStruct + + + InlineArray(2 * 1 * 3 * 4) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml new file mode 100644 index 00000000..49d01557 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyStruct + + + InlineArray(2 * 1 * 3 * 4) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml new file mode 100644 index 00000000..49d01557 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyStruct + + + InlineArray(2 * 1 * 3 * 4) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs new file mode 100644 index 00000000..0f008d07 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs @@ -0,0 +1,31 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Default.cs new file mode 100644 index 00000000..5bcd4a72 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Default.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Latest.cs new file mode 100644 index 00000000..5bcd4a72 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Latest.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Preview.cs new file mode 100644 index 00000000..5bcd4a72 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Preview.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Compatible.xml new file mode 100644 index 00000000..4b11aff9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + double + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Default.xml new file mode 100644 index 00000000..3159b1d4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Latest.xml new file mode 100644 index 00000000..3159b1d4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Preview.xml new file mode 100644 index 00000000..3159b1d4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs new file mode 100644 index 00000000..c39451f5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs @@ -0,0 +1,31 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Default.cs new file mode 100644 index 00000000..081c18c5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Default.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Latest.cs new file mode 100644 index 00000000..081c18c5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Latest.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Preview.cs new file mode 100644 index 00000000..081c18c5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Preview.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Compatible.xml new file mode 100644 index 00000000..c5769c37 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + float + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Default.xml new file mode 100644 index 00000000..8124d140 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Latest.xml new file mode 100644 index 00000000..8124d140 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Preview.xml new file mode 100644 index 00000000..8124d140 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Compatible.cs new file mode 100644 index 00000000..21094ff5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Compatible.cs @@ -0,0 +1,31 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Default.cs new file mode 100644 index 00000000..409b925b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Default.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Latest.cs new file mode 100644 index 00000000..409b925b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Latest.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Preview.cs new file mode 100644 index 00000000..409b925b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Preview.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Compatible.xml new file mode 100644 index 00000000..f770a976 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + int + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Default.xml new file mode 100644 index 00000000..692ca15b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Latest.xml new file mode 100644 index 00000000..692ca15b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Preview.xml new file mode 100644 index 00000000..692ca15b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Compatible.cs new file mode 100644 index 00000000..df6eeb6a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Compatible.cs @@ -0,0 +1,31 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Default.cs new file mode 100644 index 00000000..7d5085c4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Default.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Latest.cs new file mode 100644 index 00000000..7d5085c4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Latest.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Preview.cs new file mode 100644 index 00000000..7d5085c4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Preview.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Compatible.xml new file mode 100644 index 00000000..09962bef --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + short + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Default.xml new file mode 100644 index 00000000..6379d35b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Latest.xml new file mode 100644 index 00000000..6379d35b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Preview.xml new file mode 100644 index 00000000..6379d35b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs new file mode 100644 index 00000000..a7fa733d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs @@ -0,0 +1,31 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs new file mode 100644 index 00000000..d96fc85b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs new file mode 100644 index 00000000..d96fc85b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs new file mode 100644 index 00000000..d96fc85b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml new file mode 100644 index 00000000..fd4afb4a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + double + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml new file mode 100644 index 00000000..4e1ea441 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml new file mode 100644 index 00000000..4e1ea441 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml new file mode 100644 index 00000000..4e1ea441 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs new file mode 100644 index 00000000..ae462848 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs @@ -0,0 +1,31 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs new file mode 100644 index 00000000..1eda77b9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs new file mode 100644 index 00000000..1eda77b9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs new file mode 100644 index 00000000..1eda77b9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml new file mode 100644 index 00000000..b83794d0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + float + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml new file mode 100644 index 00000000..811f2671 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml new file mode 100644 index 00000000..811f2671 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml new file mode 100644 index 00000000..811f2671 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs new file mode 100644 index 00000000..5bd5e93d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs @@ -0,0 +1,31 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs new file mode 100644 index 00000000..9be4a403 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs new file mode 100644 index 00000000..9be4a403 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs new file mode 100644 index 00000000..9be4a403 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml new file mode 100644 index 00000000..c7d2723d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + int + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Default.xml new file mode 100644 index 00000000..17965210 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml new file mode 100644 index 00000000..17965210 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml new file mode 100644 index 00000000..17965210 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs new file mode 100644 index 00000000..20a2712b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs @@ -0,0 +1,31 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs new file mode 100644 index 00000000..5fee19db --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs new file mode 100644 index 00000000..5fee19db --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs new file mode 100644 index 00000000..5fee19db --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs @@ -0,0 +1,21 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml new file mode 100644 index 00000000..b27c3e83 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + short + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml new file mode 100644 index 00000000..67544ecd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml new file mode 100644 index 00000000..67544ecd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml new file mode 100644 index 00000000..67544ecd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..44ddef4c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Compatible.cs @@ -0,0 +1,32 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("bool")] + public byte value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Default.cs new file mode 100644 index 00000000..c06b1082 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Default.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("bool")] + public byte value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Latest.cs new file mode 100644 index 00000000..c06b1082 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Latest.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("bool")] + public byte value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Preview.cs new file mode 100644 index 00000000..c06b1082 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Preview.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("bool")] + public byte value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Compatible.xml new file mode 100644 index 00000000..027f45ad --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + byte + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Default.xml new file mode 100644 index 00000000..7331eb63 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + byte + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Latest.xml new file mode 100644 index 00000000..7331eb63 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + byte + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Preview.xml new file mode 100644 index 00000000..7331eb63 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + byte + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Compatible.cs new file mode 100644 index 00000000..1e27f423 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Compatible.cs @@ -0,0 +1,32 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("long long")] + public long value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Default.cs new file mode 100644 index 00000000..09e2cf1a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Default.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("long long")] + public long value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Latest.cs new file mode 100644 index 00000000..09e2cf1a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Latest.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("long long")] + public long value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Preview.cs new file mode 100644 index 00000000..09e2cf1a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Preview.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("long long")] + public long value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Compatible.xml new file mode 100644 index 00000000..8407d72e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + long + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Default.xml new file mode 100644 index 00000000..0767f489 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + long + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Latest.xml new file mode 100644 index 00000000..0767f489 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + long + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Preview.xml new file mode 100644 index 00000000..0767f489 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + long + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..9cc28f6c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Compatible.cs @@ -0,0 +1,32 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("signed char")] + public sbyte value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Default.cs new file mode 100644 index 00000000..0b9c9173 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Default.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("signed char")] + public sbyte value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Latest.cs new file mode 100644 index 00000000..0b9c9173 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Latest.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("signed char")] + public sbyte value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Preview.cs new file mode 100644 index 00000000..0b9c9173 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Preview.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("signed char")] + public sbyte value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Compatible.xml new file mode 100644 index 00000000..675193db --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + sbyte + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Default.xml new file mode 100644 index 00000000..4747e6ab --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + sbyte + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Latest.xml new file mode 100644 index 00000000..4747e6ab --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + sbyte + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Preview.xml new file mode 100644 index 00000000..4747e6ab --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + sbyte + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..171da97b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs @@ -0,0 +1,32 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned char")] + public byte value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Default.cs new file mode 100644 index 00000000..8de9bd64 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Default.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned char")] + public byte value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Latest.cs new file mode 100644 index 00000000..8de9bd64 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Latest.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned char")] + public byte value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Preview.cs new file mode 100644 index 00000000..8de9bd64 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Preview.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned char")] + public byte value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Compatible.xml new file mode 100644 index 00000000..fd409bc5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + byte + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Default.xml new file mode 100644 index 00000000..90368773 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + byte + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Latest.xml new file mode 100644 index 00000000..90368773 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + byte + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Preview.xml new file mode 100644 index 00000000..90368773 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + byte + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Compatible.cs new file mode 100644 index 00000000..2e843926 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Compatible.cs @@ -0,0 +1,32 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned int")] + public uint value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Default.cs new file mode 100644 index 00000000..400f71dc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Default.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned int")] + public uint value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Latest.cs new file mode 100644 index 00000000..400f71dc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Latest.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned int")] + public uint value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Preview.cs new file mode 100644 index 00000000..400f71dc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Preview.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned int")] + public uint value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Compatible.xml new file mode 100644 index 00000000..65f7549d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + uint + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Default.xml new file mode 100644 index 00000000..f8047396 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + uint + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Latest.xml new file mode 100644 index 00000000..f8047396 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + uint + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Preview.xml new file mode 100644 index 00000000..f8047396 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + uint + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs new file mode 100644 index 00000000..48443883 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs @@ -0,0 +1,32 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned long long")] + public ulong value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs new file mode 100644 index 00000000..16f19b02 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned long long")] + public ulong value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs new file mode 100644 index 00000000..16f19b02 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned long long")] + public ulong value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs new file mode 100644 index 00000000..16f19b02 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned long long")] + public ulong value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml new file mode 100644 index 00000000..bb5aa3f6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + ulong + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Default.xml new file mode 100644 index 00000000..e5a69ea6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + ulong + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml new file mode 100644 index 00000000..e5a69ea6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + ulong + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml new file mode 100644 index 00000000..e5a69ea6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + ulong + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Compatible.cs new file mode 100644 index 00000000..f2676a86 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Compatible.cs @@ -0,0 +1,32 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned short")] + public ushort value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Default.cs new file mode 100644 index 00000000..cfb5e8a5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Default.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned short")] + public ushort value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Latest.cs new file mode 100644 index 00000000..cfb5e8a5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Latest.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned short")] + public ushort value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Preview.cs new file mode 100644 index 00000000..cfb5e8a5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Preview.cs @@ -0,0 +1,22 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned short")] + public ushort value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Compatible.xml new file mode 100644 index 00000000..0710bd40 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + ushort + + + + + MyStruct + + + + MyStruct + + + MyStruct + + + MyStruct + + + ref MyStruct + + int + + + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Default.xml new file mode 100644 index 00000000..4070a1e1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + ushort + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Latest.xml new file mode 100644 index 00000000..4070a1e1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + ushort + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Preview.xml new file mode 100644 index 00000000..4070a1e1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + ushort + + + + + MyStruct + + + InlineArray(3) + + MyStruct + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.CSharp.cs new file mode 100644 index 00000000..e578cfb9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.CSharp.cs @@ -0,0 +1,26 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("double *[3]")] + public _c_e__FixedBuffer c; + + public unsafe partial struct _c_e__FixedBuffer + { + public double* e0; + public double* e1; + public double* e2; + + public ref double* this[int index] + { + get + { + fixed (double** pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.Xml.xml new file mode 100644 index 00000000..3d613894 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.Xml.xml @@ -0,0 +1,33 @@ + + + + + + double* + + + + double* + + + double* + + + double* + + + ref double* + + int + + + fixed (double** pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.CSharp.cs new file mode 100644 index 00000000..052732da --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.CSharp.cs @@ -0,0 +1,26 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("float *[3]")] + public _c_e__FixedBuffer c; + + public unsafe partial struct _c_e__FixedBuffer + { + public float* e0; + public float* e1; + public float* e2; + + public ref float* this[int index] + { + get + { + fixed (float** pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.Xml.xml new file mode 100644 index 00000000..c0facf22 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.Xml.xml @@ -0,0 +1,33 @@ + + + + + + float* + + + + float* + + + float* + + + float* + + + ref float* + + int + + + fixed (float** pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.CSharp.cs new file mode 100644 index 00000000..ba8ecc61 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.CSharp.cs @@ -0,0 +1,26 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("int *[3]")] + public _c_e__FixedBuffer c; + + public unsafe partial struct _c_e__FixedBuffer + { + public int* e0; + public int* e1; + public int* e2; + + public ref int* this[int index] + { + get + { + fixed (int** pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.Xml.xml new file mode 100644 index 00000000..f53dca6d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.Xml.xml @@ -0,0 +1,33 @@ + + + + + + int* + + + + int* + + + int* + + + int* + + + ref int* + + int + + + fixed (int** pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.CSharp.cs new file mode 100644 index 00000000..f5b8de8d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.CSharp.cs @@ -0,0 +1,26 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("short *[3]")] + public _c_e__FixedBuffer c; + + public unsafe partial struct _c_e__FixedBuffer + { + public short* e0; + public short* e1; + public short* e2; + + public ref short* this[int index] + { + get + { + fixed (short** pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.Xml.xml new file mode 100644 index 00000000..f8ce703e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.Xml.xml @@ -0,0 +1,33 @@ + + + + + + short* + + + + short* + + + short* + + + short* + + + ref short* + + int + + + fixed (short** pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs new file mode 100644 index 00000000..d0555d68 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("double[2][1][3][4]")] + public fixed double c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs new file mode 100644 index 00000000..d2bf56aa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("double[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public double e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs new file mode 100644 index 00000000..d2bf56aa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("double[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public double e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs new file mode 100644 index 00000000..d2bf56aa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("double[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public double e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml new file mode 100644 index 00000000..07b6d238 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml new file mode 100644 index 00000000..b61dbfd7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(2 * 1 * 3 * 4) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml new file mode 100644 index 00000000..b61dbfd7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(2 * 1 * 3 * 4) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml new file mode 100644 index 00000000..b61dbfd7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(2 * 1 * 3 * 4) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs new file mode 100644 index 00000000..c2beb6a8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("float[2][1][3][4]")] + public fixed float c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs new file mode 100644 index 00000000..a1359e8a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("float[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public float e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs new file mode 100644 index 00000000..a1359e8a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("float[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public float e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs new file mode 100644 index 00000000..a1359e8a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("float[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public float e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml new file mode 100644 index 00000000..f752d135 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml new file mode 100644 index 00000000..530f8eb3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(2 * 1 * 3 * 4) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml new file mode 100644 index 00000000..530f8eb3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(2 * 1 * 3 * 4) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml new file mode 100644 index 00000000..530f8eb3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(2 * 1 * 3 * 4) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs new file mode 100644 index 00000000..ab4c3b1b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("int[2][1][3][4]")] + public fixed int c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs new file mode 100644 index 00000000..eb441349 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("int[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public int e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs new file mode 100644 index 00000000..eb441349 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("int[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public int e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs new file mode 100644 index 00000000..eb441349 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("int[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public int e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml new file mode 100644 index 00000000..51f88db5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml new file mode 100644 index 00000000..a1c08109 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(2 * 1 * 3 * 4) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml new file mode 100644 index 00000000..a1c08109 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(2 * 1 * 3 * 4) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml new file mode 100644 index 00000000..a1c08109 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(2 * 1 * 3 * 4) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Compatible.cs new file mode 100644 index 00000000..13cc4b44 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("long long[2][1][3][4]")] + public fixed long c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Default.cs new file mode 100644 index 00000000..991827c4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("long long[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public long e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Latest.cs new file mode 100644 index 00000000..991827c4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("long long[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public long e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Preview.cs new file mode 100644 index 00000000..991827c4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("long long[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public long e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Compatible.xml new file mode 100644 index 00000000..75e900bf --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + long + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Default.xml new file mode 100644 index 00000000..438aeb74 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(2 * 1 * 3 * 4) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Latest.xml new file mode 100644 index 00000000..438aeb74 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(2 * 1 * 3 * 4) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Preview.xml new file mode 100644 index 00000000..438aeb74 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(2 * 1 * 3 * 4) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs new file mode 100644 index 00000000..786eef44 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("short[2][1][3][4]")] + public fixed short c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs new file mode 100644 index 00000000..fe85308d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("short[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public short e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs new file mode 100644 index 00000000..fe85308d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("short[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public short e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs new file mode 100644 index 00000000..fe85308d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("short[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public short e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml new file mode 100644 index 00000000..049c9f2b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml new file mode 100644 index 00000000..8d3a5fc2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(2 * 1 * 3 * 4) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml new file mode 100644 index 00000000..8d3a5fc2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(2 * 1 * 3 * 4) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml new file mode 100644 index 00000000..8d3a5fc2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(2 * 1 * 3 * 4) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..f63825ad --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("signed char[2][1][3][4]")] + public fixed sbyte c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Default.cs new file mode 100644 index 00000000..7fdb305a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("signed char[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Latest.cs new file mode 100644 index 00000000..7fdb305a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("signed char[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Preview.cs new file mode 100644 index 00000000..7fdb305a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("signed char[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Compatible.xml new file mode 100644 index 00000000..70a09b4b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + sbyte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Default.xml new file mode 100644 index 00000000..8bfebe63 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(2 * 1 * 3 * 4) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Latest.xml new file mode 100644 index 00000000..8bfebe63 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(2 * 1 * 3 * 4) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Preview.xml new file mode 100644 index 00000000..8bfebe63 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(2 * 1 * 3 * 4) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..0c8a2e37 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("unsigned char[2][1][3][4]")] + public fixed byte c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Default.cs new file mode 100644 index 00000000..e49861bc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned char[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public byte e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Latest.cs new file mode 100644 index 00000000..e49861bc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned char[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public byte e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Preview.cs new file mode 100644 index 00000000..e49861bc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned char[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public byte e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Compatible.xml new file mode 100644 index 00000000..eae77064 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Default.xml new file mode 100644 index 00000000..9ef24de7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(2 * 1 * 3 * 4) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Latest.xml new file mode 100644 index 00000000..9ef24de7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(2 * 1 * 3 * 4) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Preview.xml new file mode 100644 index 00000000..9ef24de7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(2 * 1 * 3 * 4) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Compatible.cs new file mode 100644 index 00000000..1c700796 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("unsigned int[2][1][3][4]")] + public fixed uint c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Default.cs new file mode 100644 index 00000000..ff139657 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned int[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public uint e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Latest.cs new file mode 100644 index 00000000..ff139657 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned int[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public uint e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Preview.cs new file mode 100644 index 00000000..ff139657 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned int[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public uint e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Compatible.xml new file mode 100644 index 00000000..89dc5c78 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Default.xml new file mode 100644 index 00000000..f2de3b72 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(2 * 1 * 3 * 4) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Latest.xml new file mode 100644 index 00000000..f2de3b72 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(2 * 1 * 3 * 4) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Preview.xml new file mode 100644 index 00000000..f2de3b72 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(2 * 1 * 3 * 4) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs new file mode 100644 index 00000000..7e80a1f5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("unsigned long long[2][1][3][4]")] + public fixed ulong c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs new file mode 100644 index 00000000..7a46b36f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned long long[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public ulong e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs new file mode 100644 index 00000000..7a46b36f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned long long[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public ulong e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs new file mode 100644 index 00000000..7a46b36f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned long long[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public ulong e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml new file mode 100644 index 00000000..5c604e8b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + ulong + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Default.xml new file mode 100644 index 00000000..1ef75447 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(2 * 1 * 3 * 4) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml new file mode 100644 index 00000000..1ef75447 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(2 * 1 * 3 * 4) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml new file mode 100644 index 00000000..1ef75447 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(2 * 1 * 3 * 4) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Compatible.cs new file mode 100644 index 00000000..41b46fe0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("unsigned short[2][1][3][4]")] + public fixed ushort c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Default.cs new file mode 100644 index 00000000..a498bd4b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned short[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public ushort e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Latest.cs new file mode 100644 index 00000000..a498bd4b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned short[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public ushort e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Preview.cs new file mode 100644 index 00000000..a498bd4b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned short[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public ushort e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Compatible.xml new file mode 100644 index 00000000..1357f155 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + ushort + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Default.xml new file mode 100644 index 00000000..6c292be6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(2 * 1 * 3 * 4) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Latest.xml new file mode 100644 index 00000000..6c292be6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(2 * 1 * 3 * 4) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Preview.xml new file mode 100644 index 00000000..6c292be6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(2 * 1 * 3 * 4) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs new file mode 100644 index 00000000..9d5d0e23 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("double[3]")] + public fixed double c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Default.cs new file mode 100644 index 00000000..7b85681d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("double[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public double e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Latest.cs new file mode 100644 index 00000000..7b85681d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("double[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public double e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Preview.cs new file mode 100644 index 00000000..7b85681d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("double[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public double e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Compatible.xml new file mode 100644 index 00000000..3be23ab1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Default.xml new file mode 100644 index 00000000..27ec8458 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(3) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Latest.xml new file mode 100644 index 00000000..27ec8458 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(3) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Preview.xml new file mode 100644 index 00000000..27ec8458 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(3) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs new file mode 100644 index 00000000..516ccdc6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("float[3]")] + public fixed float c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Default.cs new file mode 100644 index 00000000..e9f6c5a5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("float[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public float e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Latest.cs new file mode 100644 index 00000000..e9f6c5a5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("float[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public float e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Preview.cs new file mode 100644 index 00000000..e9f6c5a5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("float[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public float e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Compatible.xml new file mode 100644 index 00000000..3eb69c35 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Default.xml new file mode 100644 index 00000000..18924d1e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(3) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Latest.xml new file mode 100644 index 00000000..18924d1e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(3) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Preview.xml new file mode 100644 index 00000000..18924d1e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(3) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Compatible.cs new file mode 100644 index 00000000..d0352b52 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("int[3]")] + public fixed int c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Default.cs new file mode 100644 index 00000000..a07aef4e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("int[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Latest.cs new file mode 100644 index 00000000..a07aef4e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("int[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Preview.cs new file mode 100644 index 00000000..a07aef4e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("int[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Compatible.xml new file mode 100644 index 00000000..81d661b8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Default.xml new file mode 100644 index 00000000..79de9c08 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(3) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Latest.xml new file mode 100644 index 00000000..79de9c08 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(3) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Preview.xml new file mode 100644 index 00000000..79de9c08 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(3) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Compatible.cs new file mode 100644 index 00000000..615b82b1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("long long[3]")] + public fixed long c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Default.cs new file mode 100644 index 00000000..3b2fdb50 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("long long[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public long e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Latest.cs new file mode 100644 index 00000000..3b2fdb50 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("long long[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public long e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Preview.cs new file mode 100644 index 00000000..3b2fdb50 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("long long[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public long e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Compatible.xml new file mode 100644 index 00000000..7f002db2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + long + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Default.xml new file mode 100644 index 00000000..5a50ebeb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(3) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Latest.xml new file mode 100644 index 00000000..5a50ebeb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(3) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Preview.xml new file mode 100644 index 00000000..5a50ebeb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(3) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Compatible.cs new file mode 100644 index 00000000..f185967b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("short[3]")] + public fixed short c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Default.cs new file mode 100644 index 00000000..244f6aee --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("short[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public short e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Latest.cs new file mode 100644 index 00000000..244f6aee --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("short[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public short e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Preview.cs new file mode 100644 index 00000000..244f6aee --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("short[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public short e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Compatible.xml new file mode 100644 index 00000000..0e397a09 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Default.xml new file mode 100644 index 00000000..56287865 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(3) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Latest.xml new file mode 100644 index 00000000..56287865 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(3) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Preview.xml new file mode 100644 index 00000000..56287865 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(3) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..abb7f652 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("signed char[3]")] + public fixed sbyte c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Default.cs new file mode 100644 index 00000000..ad59c3e4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("signed char[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Latest.cs new file mode 100644 index 00000000..ad59c3e4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("signed char[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Preview.cs new file mode 100644 index 00000000..ad59c3e4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("signed char[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Compatible.xml new file mode 100644 index 00000000..7d17e781 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + sbyte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Default.xml new file mode 100644 index 00000000..ee4c40f1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(3) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Latest.xml new file mode 100644 index 00000000..ee4c40f1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(3) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Preview.xml new file mode 100644 index 00000000..ee4c40f1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(3) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..3b46bfb2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("unsigned char[3]")] + public fixed byte c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Default.cs new file mode 100644 index 00000000..3d311fa8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned char[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public byte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Latest.cs new file mode 100644 index 00000000..3d311fa8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned char[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public byte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Preview.cs new file mode 100644 index 00000000..3d311fa8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned char[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public byte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Compatible.xml new file mode 100644 index 00000000..0850a225 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Default.xml new file mode 100644 index 00000000..045ff2e7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(3) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Latest.xml new file mode 100644 index 00000000..045ff2e7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(3) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Preview.xml new file mode 100644 index 00000000..045ff2e7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(3) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Compatible.cs new file mode 100644 index 00000000..cd5f73a8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("unsigned int[3]")] + public fixed uint c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Default.cs new file mode 100644 index 00000000..fbc49772 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned int[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public uint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Latest.cs new file mode 100644 index 00000000..fbc49772 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned int[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public uint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Preview.cs new file mode 100644 index 00000000..fbc49772 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned int[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public uint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Compatible.xml new file mode 100644 index 00000000..06495e73 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Default.xml new file mode 100644 index 00000000..52aaab88 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(3) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Latest.xml new file mode 100644 index 00000000..52aaab88 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(3) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Preview.xml new file mode 100644 index 00000000..52aaab88 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(3) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs new file mode 100644 index 00000000..53c93ef3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("unsigned long long[3]")] + public fixed ulong c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs new file mode 100644 index 00000000..d5d06922 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned long long[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ulong e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs new file mode 100644 index 00000000..d5d06922 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned long long[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ulong e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs new file mode 100644 index 00000000..d5d06922 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned long long[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ulong e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml new file mode 100644 index 00000000..d3944ad0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + ulong + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Default.xml new file mode 100644 index 00000000..80d63bea --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(3) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml new file mode 100644 index 00000000..80d63bea --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(3) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml new file mode 100644 index 00000000..80d63bea --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(3) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Compatible.cs new file mode 100644 index 00000000..e4d8376e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("unsigned short[3]")] + public fixed ushort c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Default.cs new file mode 100644 index 00000000..8a7f743a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned short[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ushort e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Latest.cs new file mode 100644 index 00000000..8a7f743a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned short[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ushort e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Preview.cs new file mode 100644 index 00000000..8a7f743a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned short[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ushort e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Compatible.xml new file mode 100644 index 00000000..8acd0285 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + ushort + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Default.xml new file mode 100644 index 00000000..154ebd34 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(3) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Latest.xml new file mode 100644 index 00000000..154ebd34 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(3) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Preview.xml new file mode 100644 index 00000000..154ebd34 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(3) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs new file mode 100644 index 00000000..74452b4c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public fixed double c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs new file mode 100644 index 00000000..316ad2aa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public double e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs new file mode 100644 index 00000000..316ad2aa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public double e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs new file mode 100644 index 00000000..316ad2aa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public double e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml new file mode 100644 index 00000000..8c35c8d8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml new file mode 100644 index 00000000..b04f25a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(3) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml new file mode 100644 index 00000000..b04f25a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(3) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml new file mode 100644 index 00000000..b04f25a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(3) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs new file mode 100644 index 00000000..e4366884 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public fixed float c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs new file mode 100644 index 00000000..5a2f4f8a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public float e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs new file mode 100644 index 00000000..5a2f4f8a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public float e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs new file mode 100644 index 00000000..5a2f4f8a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public float e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml new file mode 100644 index 00000000..441b3a7f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml new file mode 100644 index 00000000..5ad6e431 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(3) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml new file mode 100644 index 00000000..5ad6e431 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(3) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml new file mode 100644 index 00000000..5ad6e431 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(3) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs new file mode 100644 index 00000000..8da8efec --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public fixed int c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs new file mode 100644 index 00000000..cddcf16e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs new file mode 100644 index 00000000..cddcf16e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs new file mode 100644 index 00000000..cddcf16e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml new file mode 100644 index 00000000..be05554b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Default.xml new file mode 100644 index 00000000..592ded57 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(3) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml new file mode 100644 index 00000000..592ded57 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(3) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml new file mode 100644 index 00000000..592ded57 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(3) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Compatible.cs new file mode 100644 index 00000000..02f87a44 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public fixed long c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Default.cs new file mode 100644 index 00000000..d488df79 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public long e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Latest.cs new file mode 100644 index 00000000..d488df79 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public long e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Preview.cs new file mode 100644 index 00000000..d488df79 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public long e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Compatible.xml new file mode 100644 index 00000000..c821688f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + long + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Default.xml new file mode 100644 index 00000000..559d2071 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(3) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Latest.xml new file mode 100644 index 00000000..559d2071 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(3) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Preview.xml new file mode 100644 index 00000000..559d2071 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(3) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs new file mode 100644 index 00000000..f2d77797 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public fixed short c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs new file mode 100644 index 00000000..9e0b9082 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public short e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs new file mode 100644 index 00000000..9e0b9082 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public short e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs new file mode 100644 index 00000000..9e0b9082 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public short e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml new file mode 100644 index 00000000..6150c726 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml new file mode 100644 index 00000000..9eddaddd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(3) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml new file mode 100644 index 00000000..9eddaddd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(3) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml new file mode 100644 index 00000000..9eddaddd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(3) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..8a5685f0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public fixed sbyte c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Default.cs new file mode 100644 index 00000000..501030e5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Latest.cs new file mode 100644 index 00000000..501030e5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Preview.cs new file mode 100644 index 00000000..501030e5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Compatible.xml new file mode 100644 index 00000000..a056420c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + sbyte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Default.xml new file mode 100644 index 00000000..02e21f41 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(3) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Latest.xml new file mode 100644 index 00000000..02e21f41 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(3) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Preview.xml new file mode 100644 index 00000000..02e21f41 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(3) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..72a1e25a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public fixed byte c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Default.cs new file mode 100644 index 00000000..68b93a7a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public byte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Latest.cs new file mode 100644 index 00000000..68b93a7a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public byte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Preview.cs new file mode 100644 index 00000000..68b93a7a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public byte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Compatible.xml new file mode 100644 index 00000000..b4fe51f0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Default.xml new file mode 100644 index 00000000..8bc90a1b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(3) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Latest.xml new file mode 100644 index 00000000..8bc90a1b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(3) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Preview.xml new file mode 100644 index 00000000..8bc90a1b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(3) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Compatible.cs new file mode 100644 index 00000000..6bec107f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public fixed uint c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Default.cs new file mode 100644 index 00000000..3d75c6d7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public uint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Latest.cs new file mode 100644 index 00000000..3d75c6d7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public uint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Preview.cs new file mode 100644 index 00000000..3d75c6d7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public uint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Compatible.xml new file mode 100644 index 00000000..a3291432 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Default.xml new file mode 100644 index 00000000..42fb438a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(3) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Latest.xml new file mode 100644 index 00000000..42fb438a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(3) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Preview.xml new file mode 100644 index 00000000..42fb438a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(3) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs new file mode 100644 index 00000000..5dbcb16d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public fixed ulong c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs new file mode 100644 index 00000000..82779d8f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ulong e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs new file mode 100644 index 00000000..82779d8f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ulong e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs new file mode 100644 index 00000000..82779d8f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ulong e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml new file mode 100644 index 00000000..23a5295f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + ulong + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Default.xml new file mode 100644 index 00000000..6353dff0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(3) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml new file mode 100644 index 00000000..6353dff0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(3) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml new file mode 100644 index 00000000..6353dff0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(3) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Compatible.cs new file mode 100644 index 00000000..aba68bc0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public fixed ushort c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Default.cs new file mode 100644 index 00000000..e837749d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ushort e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Latest.cs new file mode 100644 index 00000000..e837749d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ushort e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Preview.cs new file mode 100644 index 00000000..e837749d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ushort e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Compatible.xml new file mode 100644 index 00000000..eff33d31 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + ushort + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Default.xml new file mode 100644 index 00000000..c75e3da7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(3) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Latest.xml new file mode 100644 index 00000000..c75e3da7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(3) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Preview.xml new file mode 100644 index 00000000..c75e3da7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(3) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/GuidTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/GuidTest.CSharp.cs new file mode 100644 index 00000000..edfc8ade --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/GuidTest.CSharp.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [Guid("00000000-0000-0000-C000-000000000046")] + public partial struct MyStruct1 + { + public int x; + } + + [Guid("00000000-0000-0000-C000-000000000047")] + public partial struct MyStruct2 + { + public int x; + } + + public static partial class Methods + { + public static readonly Guid IID_MyStruct1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); + + public static readonly Guid IID_MyStruct2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/GuidTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/GuidTest.Xml.xml new file mode 100644 index 00000000..3ab1b271 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/GuidTest.Xml.xml @@ -0,0 +1,19 @@ + + + + + + int + + + + + int + + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Compatible.cs new file mode 100644 index 00000000..a222eef7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("double[]")] + public fixed double x[1]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Default.cs new file mode 100644 index 00000000..6b3782b0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Default.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("double[]")] + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + { + public double e0; + + [UnscopedRef] + public ref double this[int index] + { + get + { + return ref Unsafe.Add(ref e0, index); + } + } + + [UnscopedRef] + public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Latest.cs new file mode 100644 index 00000000..6b3782b0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Latest.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("double[]")] + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + { + public double e0; + + [UnscopedRef] + public ref double this[int index] + { + get + { + return ref Unsafe.Add(ref e0, index); + } + } + + [UnscopedRef] + public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Preview.cs new file mode 100644 index 00000000..6b3782b0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.CSharp.Preview.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("double[]")] + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + { + public double e0; + + [UnscopedRef] + public ref double this[int index] + { + get + { + return ref Unsafe.Add(ref e0, index); + } + } + + [UnscopedRef] + public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Compatible.xml new file mode 100644 index 00000000..2f140981 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Default.xml new file mode 100644 index 00000000..1fe6bb16 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Default.xml @@ -0,0 +1,31 @@ + + + + + + double + + + + double + + + ref double + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<double> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Latest.xml new file mode 100644 index 00000000..1fe6bb16 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Latest.xml @@ -0,0 +1,31 @@ + + + + + + double + + + + double + + + ref double + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<double> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Preview.xml new file mode 100644 index 00000000..1fe6bb16 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_double_5Fdouble.Xml.Preview.xml @@ -0,0 +1,31 @@ + + + + + + double + + + + double + + + ref double + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<double> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Compatible.cs new file mode 100644 index 00000000..5c6ec6a6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("float[]")] + public fixed float x[1]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Default.cs new file mode 100644 index 00000000..198af032 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Default.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("float[]")] + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + { + public float e0; + + [UnscopedRef] + public ref float this[int index] + { + get + { + return ref Unsafe.Add(ref e0, index); + } + } + + [UnscopedRef] + public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Latest.cs new file mode 100644 index 00000000..198af032 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Latest.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("float[]")] + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + { + public float e0; + + [UnscopedRef] + public ref float this[int index] + { + get + { + return ref Unsafe.Add(ref e0, index); + } + } + + [UnscopedRef] + public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Preview.cs new file mode 100644 index 00000000..198af032 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.CSharp.Preview.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("float[]")] + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + { + public float e0; + + [UnscopedRef] + public ref float this[int index] + { + get + { + return ref Unsafe.Add(ref e0, index); + } + } + + [UnscopedRef] + public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Compatible.xml new file mode 100644 index 00000000..da0f42b5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Default.xml new file mode 100644 index 00000000..f006108f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Default.xml @@ -0,0 +1,31 @@ + + + + + + float + + + + float + + + ref float + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<float> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Latest.xml new file mode 100644 index 00000000..f006108f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Latest.xml @@ -0,0 +1,31 @@ + + + + + + float + + + + float + + + ref float + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<float> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Preview.xml new file mode 100644 index 00000000..f006108f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_float_5Ffloat.Xml.Preview.xml @@ -0,0 +1,31 @@ + + + + + + float + + + + float + + + ref float + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<float> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Compatible.cs new file mode 100644 index 00000000..bfd8b505 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("int[]")] + public fixed int x[1]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Default.cs new file mode 100644 index 00000000..fc0ac830 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Default.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("int[]")] + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + { + public int e0; + + [UnscopedRef] + public ref int this[int index] + { + get + { + return ref Unsafe.Add(ref e0, index); + } + } + + [UnscopedRef] + public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Latest.cs new file mode 100644 index 00000000..fc0ac830 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Latest.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("int[]")] + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + { + public int e0; + + [UnscopedRef] + public ref int this[int index] + { + get + { + return ref Unsafe.Add(ref e0, index); + } + } + + [UnscopedRef] + public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Preview.cs new file mode 100644 index 00000000..fc0ac830 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.CSharp.Preview.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("int[]")] + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + { + public int e0; + + [UnscopedRef] + public ref int this[int index] + { + get + { + return ref Unsafe.Add(ref e0, index); + } + } + + [UnscopedRef] + public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Compatible.xml new file mode 100644 index 00000000..af5ad1b5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Default.xml new file mode 100644 index 00000000..fc39d3ce --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Default.xml @@ -0,0 +1,31 @@ + + + + + + int + + + + int + + + ref int + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<int> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Latest.xml new file mode 100644 index 00000000..fc39d3ce --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Latest.xml @@ -0,0 +1,31 @@ + + + + + + int + + + + int + + + ref int + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<int> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Preview.xml new file mode 100644 index 00000000..fc39d3ce --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_int_5Fint.Xml.Preview.xml @@ -0,0 +1,31 @@ + + + + + + int + + + + int + + + ref int + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<int> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Compatible.cs new file mode 100644 index 00000000..cabb5ac6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Compatible.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + [NativeTypeName("short[]")] + public fixed short x[1]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Default.cs new file mode 100644 index 00000000..89da35a1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Default.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("short[]")] + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + { + public short e0; + + [UnscopedRef] + public ref short this[int index] + { + get + { + return ref Unsafe.Add(ref e0, index); + } + } + + [UnscopedRef] + public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Latest.cs new file mode 100644 index 00000000..89da35a1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Latest.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("short[]")] + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + { + public short e0; + + [UnscopedRef] + public ref short this[int index] + { + get + { + return ref Unsafe.Add(ref e0, index); + } + } + + [UnscopedRef] + public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Preview.cs new file mode 100644 index 00000000..89da35a1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.CSharp.Preview.cs @@ -0,0 +1,30 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("short[]")] + public _x_e__FixedBuffer x; + + public partial struct _x_e__FixedBuffer + { + public short e0; + + [UnscopedRef] + public ref short this[int index] + { + get + { + return ref Unsafe.Add(ref e0, index); + } + } + + [UnscopedRef] + public Span AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Compatible.xml new file mode 100644 index 00000000..951de81b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Default.xml new file mode 100644 index 00000000..6d6c0c42 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Default.xml @@ -0,0 +1,31 @@ + + + + + + short + + + + short + + + ref short + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<short> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Latest.xml new file mode 100644 index 00000000..6d6c0c42 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Latest.xml @@ -0,0 +1,31 @@ + + + + + + short + + + + short + + + ref short + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<short> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Preview.xml new file mode 100644 index 00000000..6d6c0c42 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/IncompleteArraySizeTest_short_5Fshort.Xml.Preview.xml @@ -0,0 +1,31 @@ + + + + + + short + + + + short + + + ref short + + int + + + return ref Unsafe.Add(ref e0, index); + + + + Span<short> + + int + + MemoryMarshal.CreateSpan(ref e0, length); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceTest.CSharp.cs new file mode 100644 index 00000000..86711f90 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceTest.CSharp.cs @@ -0,0 +1,28 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1A + { + public int x; + + public int y; + } + + public partial struct MyStruct1B + { + public int x; + + public int y; + } + + [NativeTypeName("struct MyStruct2 : MyStruct1A, MyStruct1B")] + public partial struct MyStruct2 + { + public MyStruct1A Base1; + + public MyStruct1B Base2; + + public int z; + + public int w; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceTest.Xml.xml new file mode 100644 index 00000000..01e2cf9c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceTest.Xml.xml @@ -0,0 +1,35 @@ + + + + + + int + + + int + + + + + int + + + int + + + + + MyStruct1A + + + MyStruct1B + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceWithNativeInheritanceAttributeTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceWithNativeInheritanceAttributeTest.CSharp.cs new file mode 100644 index 00000000..b0652319 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceWithNativeInheritanceAttributeTest.CSharp.cs @@ -0,0 +1,29 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1A + { + public int x; + + public int y; + } + + public partial struct MyStruct1B + { + public int x; + + public int y; + } + + [NativeTypeName("struct MyStruct2 : MyStruct1A, MyStruct1B")] + [NativeInheritance("MyStruct1B")] + public partial struct MyStruct2 + { + public MyStruct1A Base1; + + public MyStruct1B Base2; + + public int z; + + public int w; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceWithNativeInheritanceAttributeTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceWithNativeInheritanceAttributeTest.Xml.xml new file mode 100644 index 00000000..5fae7ad1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/InheritanceWithNativeInheritanceAttributeTest.Xml.xml @@ -0,0 +1,35 @@ + + + + + + int + + + int + + + + + int + + + int + + + + + MyStruct1A + + + MyStruct1B + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Compatible.cs new file mode 100644 index 00000000..0524babb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Compatible.cs @@ -0,0 +1,175 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + public unsafe partial struct MyStruct + { + public double x; + + public double y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + public ref double z + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->z; + } + } + } + + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->w; + } + } + } + + public ref double value1 + { + get + { + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) + { + return ref pField->value1; + } + } + } + + public ref double value + { + get + { + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous_e__Struct* pField = &Anonymous.Anonymous1.Anonymous) + { + return ref pField->value; + } + } + } + + public ref double value2 + { + get + { + fixed (_Anonymous_e__Struct._Anonymous2_e__Union* pField = &Anonymous.Anonymous2) + { + return ref pField->value2; + } + } + } + + public ref MyUnion u + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->u; + } + } + } + + public ref double buffer1 + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer1[0]; + } + } + } + + public ref _Anonymous_e__Struct._buffer2_e__FixedBuffer buffer2 + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer2; + } + } + } + + public unsafe partial struct _Anonymous_e__Struct + { + public double z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("double[4]")] + public fixed double buffer1[4]; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public double value; + } + + public unsafe partial struct _Anonymous1_e__Struct + { + public double value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public double value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public double value2; + } + + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + public MyUnion e3; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Default.cs new file mode 100644 index 00000000..d51e6cb2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Default.cs @@ -0,0 +1,155 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + public partial struct MyStruct + { + public double x; + + public double y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref double z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + return ref Anonymous.w; + } + } + + [UnscopedRef] + public ref double value1 + { + get + { + return ref Anonymous.Anonymous1.value1; + } + } + + [UnscopedRef] + public ref double value + { + get + { + return ref Anonymous.Anonymous1.Anonymous.value; + } + } + + [UnscopedRef] + public ref double value2 + { + get + { + return ref Anonymous.Anonymous2.value2; + } + } + + [UnscopedRef] + public ref MyUnion u + { + get + { + return ref Anonymous.u; + } + } + + [UnscopedRef] + public Span buffer1 + { + get + { + return Anonymous.buffer1; + } + } + + [UnscopedRef] + public Span buffer2 + { + get + { + return Anonymous.buffer2; + } + } + + public partial struct _Anonymous_e__Struct + { + public double z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("double[4]")] + public _buffer1_e__FixedBuffer buffer1; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public double value; + } + + public partial struct _Anonymous1_e__Struct + { + public double value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public double value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public double value2; + } + + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + { + public double e0; + } + + [InlineArray(4)] + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Latest.cs new file mode 100644 index 00000000..d51e6cb2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Latest.cs @@ -0,0 +1,155 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + public partial struct MyStruct + { + public double x; + + public double y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref double z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + return ref Anonymous.w; + } + } + + [UnscopedRef] + public ref double value1 + { + get + { + return ref Anonymous.Anonymous1.value1; + } + } + + [UnscopedRef] + public ref double value + { + get + { + return ref Anonymous.Anonymous1.Anonymous.value; + } + } + + [UnscopedRef] + public ref double value2 + { + get + { + return ref Anonymous.Anonymous2.value2; + } + } + + [UnscopedRef] + public ref MyUnion u + { + get + { + return ref Anonymous.u; + } + } + + [UnscopedRef] + public Span buffer1 + { + get + { + return Anonymous.buffer1; + } + } + + [UnscopedRef] + public Span buffer2 + { + get + { + return Anonymous.buffer2; + } + } + + public partial struct _Anonymous_e__Struct + { + public double z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("double[4]")] + public _buffer1_e__FixedBuffer buffer1; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public double value; + } + + public partial struct _Anonymous1_e__Struct + { + public double value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public double value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public double value2; + } + + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + { + public double e0; + } + + [InlineArray(4)] + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Preview.cs new file mode 100644 index 00000000..d51e6cb2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.CSharp.Preview.cs @@ -0,0 +1,155 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + public partial struct MyStruct + { + public double x; + + public double y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref double z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + return ref Anonymous.w; + } + } + + [UnscopedRef] + public ref double value1 + { + get + { + return ref Anonymous.Anonymous1.value1; + } + } + + [UnscopedRef] + public ref double value + { + get + { + return ref Anonymous.Anonymous1.Anonymous.value; + } + } + + [UnscopedRef] + public ref double value2 + { + get + { + return ref Anonymous.Anonymous2.value2; + } + } + + [UnscopedRef] + public ref MyUnion u + { + get + { + return ref Anonymous.u; + } + } + + [UnscopedRef] + public Span buffer1 + { + get + { + return Anonymous.buffer1; + } + } + + [UnscopedRef] + public Span buffer2 + { + get + { + return Anonymous.buffer2; + } + } + + public partial struct _Anonymous_e__Struct + { + public double z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("double[4]")] + public _buffer1_e__FixedBuffer buffer1; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public double value; + } + + public partial struct _Anonymous1_e__Struct + { + public double value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public double value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public double value2; + } + + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + { + public double e0; + } + + [InlineArray(4)] + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Compatible.xml new file mode 100644 index 00000000..4c1c7ce6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Compatible.xml @@ -0,0 +1,165 @@ + + + + + + double + + + + + double + + + double + + + _Anonymous_e__Struct + + + ref double + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->z; + } + + + + ref _Anonymous_e__Struct._w_e__Struct + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->w; + } + + + + ref double + + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) + { + return ref pField->value1; + } + + + + ref double + + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous_e__Struct* pField = &Anonymous.Anonymous1.Anonymous) + { + return ref pField->value; + } + + + + ref double + + fixed (_Anonymous_e__Struct._Anonymous2_e__Union* pField = &Anonymous.Anonymous2) + { + return ref pField->value2; + } + + + + ref MyUnion + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->u; + } + + + + ref double + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer1[0]; + } + + + + ref _Anonymous_e__Struct._buffer2_e__FixedBuffer + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer2; + } + + + + + double + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + double + + + MyUnion + + + + double + + + + + double + + + _Anonymous_e__Struct + + + + double + + + + + + double + + + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Default.xml new file mode 100644 index 00000000..0a49aae3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Default.xml @@ -0,0 +1,127 @@ + + + + + + double + + + + + double + + + double + + + _Anonymous_e__Struct + + + ref double + + return ref Anonymous.z; + + + + ref _Anonymous_e__Struct._w_e__Struct + + return ref Anonymous.w; + + + + ref double + + return ref Anonymous.Anonymous1.value1; + + + + ref double + + return ref Anonymous.Anonymous1.Anonymous.value; + + + + ref double + + return ref Anonymous.Anonymous2.value2; + + + + ref MyUnion + + return ref Anonymous.u; + + + + Span<double> + + return Anonymous.buffer1; + + + + Span<MyUnion> + + return Anonymous.buffer2; + + + + + double + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + double + + + MyUnion + + + + double + + + + + double + + + _Anonymous_e__Struct + + + + double + + + + + + double + + + + InlineArray(4) + + double + + + + InlineArray(4) + + MyUnion + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Latest.xml new file mode 100644 index 00000000..0a49aae3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Latest.xml @@ -0,0 +1,127 @@ + + + + + + double + + + + + double + + + double + + + _Anonymous_e__Struct + + + ref double + + return ref Anonymous.z; + + + + ref _Anonymous_e__Struct._w_e__Struct + + return ref Anonymous.w; + + + + ref double + + return ref Anonymous.Anonymous1.value1; + + + + ref double + + return ref Anonymous.Anonymous1.Anonymous.value; + + + + ref double + + return ref Anonymous.Anonymous2.value2; + + + + ref MyUnion + + return ref Anonymous.u; + + + + Span<double> + + return Anonymous.buffer1; + + + + Span<MyUnion> + + return Anonymous.buffer2; + + + + + double + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + double + + + MyUnion + + + + double + + + + + double + + + _Anonymous_e__Struct + + + + double + + + + + + double + + + + InlineArray(4) + + double + + + + InlineArray(4) + + MyUnion + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Preview.xml new file mode 100644 index 00000000..0a49aae3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_double_5Fdouble_5F10_5F5.Xml.Preview.xml @@ -0,0 +1,127 @@ + + + + + + double + + + + + double + + + double + + + _Anonymous_e__Struct + + + ref double + + return ref Anonymous.z; + + + + ref _Anonymous_e__Struct._w_e__Struct + + return ref Anonymous.w; + + + + ref double + + return ref Anonymous.Anonymous1.value1; + + + + ref double + + return ref Anonymous.Anonymous1.Anonymous.value; + + + + ref double + + return ref Anonymous.Anonymous2.value2; + + + + ref MyUnion + + return ref Anonymous.u; + + + + Span<double> + + return Anonymous.buffer1; + + + + Span<MyUnion> + + return Anonymous.buffer2; + + + + + double + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + double + + + MyUnion + + + + double + + + + + double + + + _Anonymous_e__Struct + + + + double + + + + + + double + + + + InlineArray(4) + + double + + + + InlineArray(4) + + MyUnion + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Compatible.cs new file mode 100644 index 00000000..7c929e5b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Compatible.cs @@ -0,0 +1,175 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + public unsafe partial struct MyStruct + { + public float x; + + public float y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + public ref float z + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->z; + } + } + } + + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->w; + } + } + } + + public ref float value1 + { + get + { + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) + { + return ref pField->value1; + } + } + } + + public ref float value + { + get + { + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous_e__Struct* pField = &Anonymous.Anonymous1.Anonymous) + { + return ref pField->value; + } + } + } + + public ref float value2 + { + get + { + fixed (_Anonymous_e__Struct._Anonymous2_e__Union* pField = &Anonymous.Anonymous2) + { + return ref pField->value2; + } + } + } + + public ref MyUnion u + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->u; + } + } + } + + public ref float buffer1 + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer1[0]; + } + } + } + + public ref _Anonymous_e__Struct._buffer2_e__FixedBuffer buffer2 + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer2; + } + } + } + + public unsafe partial struct _Anonymous_e__Struct + { + public float z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("float[4]")] + public fixed float buffer1[4]; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public float value; + } + + public unsafe partial struct _Anonymous1_e__Struct + { + public float value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public float value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public float value2; + } + + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + public MyUnion e3; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Default.cs new file mode 100644 index 00000000..721f7b22 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Default.cs @@ -0,0 +1,155 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + public partial struct MyStruct + { + public float x; + + public float y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref float z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + return ref Anonymous.w; + } + } + + [UnscopedRef] + public ref float value1 + { + get + { + return ref Anonymous.Anonymous1.value1; + } + } + + [UnscopedRef] + public ref float value + { + get + { + return ref Anonymous.Anonymous1.Anonymous.value; + } + } + + [UnscopedRef] + public ref float value2 + { + get + { + return ref Anonymous.Anonymous2.value2; + } + } + + [UnscopedRef] + public ref MyUnion u + { + get + { + return ref Anonymous.u; + } + } + + [UnscopedRef] + public Span buffer1 + { + get + { + return Anonymous.buffer1; + } + } + + [UnscopedRef] + public Span buffer2 + { + get + { + return Anonymous.buffer2; + } + } + + public partial struct _Anonymous_e__Struct + { + public float z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("float[4]")] + public _buffer1_e__FixedBuffer buffer1; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public float value; + } + + public partial struct _Anonymous1_e__Struct + { + public float value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public float value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public float value2; + } + + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + { + public float e0; + } + + [InlineArray(4)] + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Latest.cs new file mode 100644 index 00000000..721f7b22 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Latest.cs @@ -0,0 +1,155 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + public partial struct MyStruct + { + public float x; + + public float y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref float z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + return ref Anonymous.w; + } + } + + [UnscopedRef] + public ref float value1 + { + get + { + return ref Anonymous.Anonymous1.value1; + } + } + + [UnscopedRef] + public ref float value + { + get + { + return ref Anonymous.Anonymous1.Anonymous.value; + } + } + + [UnscopedRef] + public ref float value2 + { + get + { + return ref Anonymous.Anonymous2.value2; + } + } + + [UnscopedRef] + public ref MyUnion u + { + get + { + return ref Anonymous.u; + } + } + + [UnscopedRef] + public Span buffer1 + { + get + { + return Anonymous.buffer1; + } + } + + [UnscopedRef] + public Span buffer2 + { + get + { + return Anonymous.buffer2; + } + } + + public partial struct _Anonymous_e__Struct + { + public float z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("float[4]")] + public _buffer1_e__FixedBuffer buffer1; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public float value; + } + + public partial struct _Anonymous1_e__Struct + { + public float value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public float value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public float value2; + } + + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + { + public float e0; + } + + [InlineArray(4)] + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Preview.cs new file mode 100644 index 00000000..721f7b22 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.CSharp.Preview.cs @@ -0,0 +1,155 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + public partial struct MyStruct + { + public float x; + + public float y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref float z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + return ref Anonymous.w; + } + } + + [UnscopedRef] + public ref float value1 + { + get + { + return ref Anonymous.Anonymous1.value1; + } + } + + [UnscopedRef] + public ref float value + { + get + { + return ref Anonymous.Anonymous1.Anonymous.value; + } + } + + [UnscopedRef] + public ref float value2 + { + get + { + return ref Anonymous.Anonymous2.value2; + } + } + + [UnscopedRef] + public ref MyUnion u + { + get + { + return ref Anonymous.u; + } + } + + [UnscopedRef] + public Span buffer1 + { + get + { + return Anonymous.buffer1; + } + } + + [UnscopedRef] + public Span buffer2 + { + get + { + return Anonymous.buffer2; + } + } + + public partial struct _Anonymous_e__Struct + { + public float z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("float[4]")] + public _buffer1_e__FixedBuffer buffer1; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public float value; + } + + public partial struct _Anonymous1_e__Struct + { + public float value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public float value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public float value2; + } + + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + { + public float e0; + } + + [InlineArray(4)] + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Compatible.xml new file mode 100644 index 00000000..6124f5f2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Compatible.xml @@ -0,0 +1,165 @@ + + + + + + float + + + + + float + + + float + + + _Anonymous_e__Struct + + + ref float + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->z; + } + + + + ref _Anonymous_e__Struct._w_e__Struct + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->w; + } + + + + ref float + + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) + { + return ref pField->value1; + } + + + + ref float + + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous_e__Struct* pField = &Anonymous.Anonymous1.Anonymous) + { + return ref pField->value; + } + + + + ref float + + fixed (_Anonymous_e__Struct._Anonymous2_e__Union* pField = &Anonymous.Anonymous2) + { + return ref pField->value2; + } + + + + ref MyUnion + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->u; + } + + + + ref float + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer1[0]; + } + + + + ref _Anonymous_e__Struct._buffer2_e__FixedBuffer + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer2; + } + + + + + float + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + float + + + MyUnion + + + + float + + + + + float + + + _Anonymous_e__Struct + + + + float + + + + + + float + + + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Default.xml new file mode 100644 index 00000000..b4b5d559 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Default.xml @@ -0,0 +1,127 @@ + + + + + + float + + + + + float + + + float + + + _Anonymous_e__Struct + + + ref float + + return ref Anonymous.z; + + + + ref _Anonymous_e__Struct._w_e__Struct + + return ref Anonymous.w; + + + + ref float + + return ref Anonymous.Anonymous1.value1; + + + + ref float + + return ref Anonymous.Anonymous1.Anonymous.value; + + + + ref float + + return ref Anonymous.Anonymous2.value2; + + + + ref MyUnion + + return ref Anonymous.u; + + + + Span<float> + + return Anonymous.buffer1; + + + + Span<MyUnion> + + return Anonymous.buffer2; + + + + + float + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + float + + + MyUnion + + + + float + + + + + float + + + _Anonymous_e__Struct + + + + float + + + + + + float + + + + InlineArray(4) + + float + + + + InlineArray(4) + + MyUnion + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Latest.xml new file mode 100644 index 00000000..b4b5d559 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Latest.xml @@ -0,0 +1,127 @@ + + + + + + float + + + + + float + + + float + + + _Anonymous_e__Struct + + + ref float + + return ref Anonymous.z; + + + + ref _Anonymous_e__Struct._w_e__Struct + + return ref Anonymous.w; + + + + ref float + + return ref Anonymous.Anonymous1.value1; + + + + ref float + + return ref Anonymous.Anonymous1.Anonymous.value; + + + + ref float + + return ref Anonymous.Anonymous2.value2; + + + + ref MyUnion + + return ref Anonymous.u; + + + + Span<float> + + return Anonymous.buffer1; + + + + Span<MyUnion> + + return Anonymous.buffer2; + + + + + float + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + float + + + MyUnion + + + + float + + + + + float + + + _Anonymous_e__Struct + + + + float + + + + + + float + + + + InlineArray(4) + + float + + + + InlineArray(4) + + MyUnion + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Preview.xml new file mode 100644 index 00000000..b4b5d559 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_float_5Ffloat_5F10_5F5.Xml.Preview.xml @@ -0,0 +1,127 @@ + + + + + + float + + + + + float + + + float + + + _Anonymous_e__Struct + + + ref float + + return ref Anonymous.z; + + + + ref _Anonymous_e__Struct._w_e__Struct + + return ref Anonymous.w; + + + + ref float + + return ref Anonymous.Anonymous1.value1; + + + + ref float + + return ref Anonymous.Anonymous1.Anonymous.value; + + + + ref float + + return ref Anonymous.Anonymous2.value2; + + + + ref MyUnion + + return ref Anonymous.u; + + + + Span<float> + + return Anonymous.buffer1; + + + + Span<MyUnion> + + return Anonymous.buffer2; + + + + + float + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + float + + + MyUnion + + + + float + + + + + float + + + _Anonymous_e__Struct + + + + float + + + + + + float + + + + InlineArray(4) + + float + + + + InlineArray(4) + + MyUnion + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Compatible.cs new file mode 100644 index 00000000..58f2acf4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Compatible.cs @@ -0,0 +1,175 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + public unsafe partial struct MyStruct + { + public int x; + + public int y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + public ref int z + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->z; + } + } + } + + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->w; + } + } + } + + public ref int value1 + { + get + { + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) + { + return ref pField->value1; + } + } + } + + public ref int value + { + get + { + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous_e__Struct* pField = &Anonymous.Anonymous1.Anonymous) + { + return ref pField->value; + } + } + } + + public ref int value2 + { + get + { + fixed (_Anonymous_e__Struct._Anonymous2_e__Union* pField = &Anonymous.Anonymous2) + { + return ref pField->value2; + } + } + } + + public ref MyUnion u + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->u; + } + } + } + + public ref int buffer1 + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer1[0]; + } + } + } + + public ref _Anonymous_e__Struct._buffer2_e__FixedBuffer buffer2 + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer2; + } + } + } + + public unsafe partial struct _Anonymous_e__Struct + { + public int z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("int[4]")] + public fixed int buffer1[4]; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public int value; + } + + public unsafe partial struct _Anonymous1_e__Struct + { + public int value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public int value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public int value2; + } + + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + public MyUnion e3; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Default.cs new file mode 100644 index 00000000..2f773ed0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Default.cs @@ -0,0 +1,155 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + public partial struct MyStruct + { + public int x; + + public int y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + return ref Anonymous.w; + } + } + + [UnscopedRef] + public ref int value1 + { + get + { + return ref Anonymous.Anonymous1.value1; + } + } + + [UnscopedRef] + public ref int value + { + get + { + return ref Anonymous.Anonymous1.Anonymous.value; + } + } + + [UnscopedRef] + public ref int value2 + { + get + { + return ref Anonymous.Anonymous2.value2; + } + } + + [UnscopedRef] + public ref MyUnion u + { + get + { + return ref Anonymous.u; + } + } + + [UnscopedRef] + public Span buffer1 + { + get + { + return Anonymous.buffer1; + } + } + + [UnscopedRef] + public Span buffer2 + { + get + { + return Anonymous.buffer2; + } + } + + public partial struct _Anonymous_e__Struct + { + public int z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("int[4]")] + public _buffer1_e__FixedBuffer buffer1; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public int value; + } + + public partial struct _Anonymous1_e__Struct + { + public int value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public int value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public int value2; + } + + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + { + public int e0; + } + + [InlineArray(4)] + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Latest.cs new file mode 100644 index 00000000..2f773ed0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Latest.cs @@ -0,0 +1,155 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + public partial struct MyStruct + { + public int x; + + public int y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + return ref Anonymous.w; + } + } + + [UnscopedRef] + public ref int value1 + { + get + { + return ref Anonymous.Anonymous1.value1; + } + } + + [UnscopedRef] + public ref int value + { + get + { + return ref Anonymous.Anonymous1.Anonymous.value; + } + } + + [UnscopedRef] + public ref int value2 + { + get + { + return ref Anonymous.Anonymous2.value2; + } + } + + [UnscopedRef] + public ref MyUnion u + { + get + { + return ref Anonymous.u; + } + } + + [UnscopedRef] + public Span buffer1 + { + get + { + return Anonymous.buffer1; + } + } + + [UnscopedRef] + public Span buffer2 + { + get + { + return Anonymous.buffer2; + } + } + + public partial struct _Anonymous_e__Struct + { + public int z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("int[4]")] + public _buffer1_e__FixedBuffer buffer1; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public int value; + } + + public partial struct _Anonymous1_e__Struct + { + public int value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public int value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public int value2; + } + + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + { + public int e0; + } + + [InlineArray(4)] + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Preview.cs new file mode 100644 index 00000000..2f773ed0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.CSharp.Preview.cs @@ -0,0 +1,155 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + public partial struct MyStruct + { + public int x; + + public int y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + return ref Anonymous.w; + } + } + + [UnscopedRef] + public ref int value1 + { + get + { + return ref Anonymous.Anonymous1.value1; + } + } + + [UnscopedRef] + public ref int value + { + get + { + return ref Anonymous.Anonymous1.Anonymous.value; + } + } + + [UnscopedRef] + public ref int value2 + { + get + { + return ref Anonymous.Anonymous2.value2; + } + } + + [UnscopedRef] + public ref MyUnion u + { + get + { + return ref Anonymous.u; + } + } + + [UnscopedRef] + public Span buffer1 + { + get + { + return Anonymous.buffer1; + } + } + + [UnscopedRef] + public Span buffer2 + { + get + { + return Anonymous.buffer2; + } + } + + public partial struct _Anonymous_e__Struct + { + public int z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("int[4]")] + public _buffer1_e__FixedBuffer buffer1; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public int value; + } + + public partial struct _Anonymous1_e__Struct + { + public int value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public int value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public int value2; + } + + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + { + public int e0; + } + + [InlineArray(4)] + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Compatible.xml new file mode 100644 index 00000000..44418cea --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Compatible.xml @@ -0,0 +1,165 @@ + + + + + + int + + + + + int + + + int + + + _Anonymous_e__Struct + + + ref int + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->z; + } + + + + ref _Anonymous_e__Struct._w_e__Struct + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->w; + } + + + + ref int + + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) + { + return ref pField->value1; + } + + + + ref int + + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous_e__Struct* pField = &Anonymous.Anonymous1.Anonymous) + { + return ref pField->value; + } + + + + ref int + + fixed (_Anonymous_e__Struct._Anonymous2_e__Union* pField = &Anonymous.Anonymous2) + { + return ref pField->value2; + } + + + + ref MyUnion + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->u; + } + + + + ref int + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer1[0]; + } + + + + ref _Anonymous_e__Struct._buffer2_e__FixedBuffer + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer2; + } + + + + + int + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + int + + + MyUnion + + + + int + + + + + int + + + _Anonymous_e__Struct + + + + int + + + + + + int + + + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Default.xml new file mode 100644 index 00000000..7a4a63ab --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Default.xml @@ -0,0 +1,127 @@ + + + + + + int + + + + + int + + + int + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.z; + + + + ref _Anonymous_e__Struct._w_e__Struct + + return ref Anonymous.w; + + + + ref int + + return ref Anonymous.Anonymous1.value1; + + + + ref int + + return ref Anonymous.Anonymous1.Anonymous.value; + + + + ref int + + return ref Anonymous.Anonymous2.value2; + + + + ref MyUnion + + return ref Anonymous.u; + + + + Span<int> + + return Anonymous.buffer1; + + + + Span<MyUnion> + + return Anonymous.buffer2; + + + + + int + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + int + + + MyUnion + + + + int + + + + + int + + + _Anonymous_e__Struct + + + + int + + + + + + int + + + + InlineArray(4) + + int + + + + InlineArray(4) + + MyUnion + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Latest.xml new file mode 100644 index 00000000..7a4a63ab --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Latest.xml @@ -0,0 +1,127 @@ + + + + + + int + + + + + int + + + int + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.z; + + + + ref _Anonymous_e__Struct._w_e__Struct + + return ref Anonymous.w; + + + + ref int + + return ref Anonymous.Anonymous1.value1; + + + + ref int + + return ref Anonymous.Anonymous1.Anonymous.value; + + + + ref int + + return ref Anonymous.Anonymous2.value2; + + + + ref MyUnion + + return ref Anonymous.u; + + + + Span<int> + + return Anonymous.buffer1; + + + + Span<MyUnion> + + return Anonymous.buffer2; + + + + + int + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + int + + + MyUnion + + + + int + + + + + int + + + _Anonymous_e__Struct + + + + int + + + + + + int + + + + InlineArray(4) + + int + + + + InlineArray(4) + + MyUnion + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Preview.xml new file mode 100644 index 00000000..7a4a63ab --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_int_5Fint_5F10_5F5.Xml.Preview.xml @@ -0,0 +1,127 @@ + + + + + + int + + + + + int + + + int + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.z; + + + + ref _Anonymous_e__Struct._w_e__Struct + + return ref Anonymous.w; + + + + ref int + + return ref Anonymous.Anonymous1.value1; + + + + ref int + + return ref Anonymous.Anonymous1.Anonymous.value; + + + + ref int + + return ref Anonymous.Anonymous2.value2; + + + + ref MyUnion + + return ref Anonymous.u; + + + + Span<int> + + return Anonymous.buffer1; + + + + Span<MyUnion> + + return Anonymous.buffer2; + + + + + int + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + int + + + MyUnion + + + + int + + + + + int + + + _Anonymous_e__Struct + + + + int + + + + + + int + + + + InlineArray(4) + + int + + + + InlineArray(4) + + MyUnion + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Compatible.cs new file mode 100644 index 00000000..cdae9f20 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Compatible.cs @@ -0,0 +1,175 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + public unsafe partial struct MyStruct + { + public short x; + + public short y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + public ref short z + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->z; + } + } + } + + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->w; + } + } + } + + public ref short value1 + { + get + { + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) + { + return ref pField->value1; + } + } + } + + public ref short value + { + get + { + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous_e__Struct* pField = &Anonymous.Anonymous1.Anonymous) + { + return ref pField->value; + } + } + } + + public ref short value2 + { + get + { + fixed (_Anonymous_e__Struct._Anonymous2_e__Union* pField = &Anonymous.Anonymous2) + { + return ref pField->value2; + } + } + } + + public ref MyUnion u + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->u; + } + } + } + + public ref short buffer1 + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer1[0]; + } + } + } + + public ref _Anonymous_e__Struct._buffer2_e__FixedBuffer buffer2 + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer2; + } + } + } + + public unsafe partial struct _Anonymous_e__Struct + { + public short z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("short[4]")] + public fixed short buffer1[4]; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public short value; + } + + public unsafe partial struct _Anonymous1_e__Struct + { + public short value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public short value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public short value2; + } + + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + public MyUnion e3; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Default.cs new file mode 100644 index 00000000..b31e1091 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Default.cs @@ -0,0 +1,155 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + public partial struct MyStruct + { + public short x; + + public short y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref short z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + return ref Anonymous.w; + } + } + + [UnscopedRef] + public ref short value1 + { + get + { + return ref Anonymous.Anonymous1.value1; + } + } + + [UnscopedRef] + public ref short value + { + get + { + return ref Anonymous.Anonymous1.Anonymous.value; + } + } + + [UnscopedRef] + public ref short value2 + { + get + { + return ref Anonymous.Anonymous2.value2; + } + } + + [UnscopedRef] + public ref MyUnion u + { + get + { + return ref Anonymous.u; + } + } + + [UnscopedRef] + public Span buffer1 + { + get + { + return Anonymous.buffer1; + } + } + + [UnscopedRef] + public Span buffer2 + { + get + { + return Anonymous.buffer2; + } + } + + public partial struct _Anonymous_e__Struct + { + public short z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("short[4]")] + public _buffer1_e__FixedBuffer buffer1; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public short value; + } + + public partial struct _Anonymous1_e__Struct + { + public short value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public short value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public short value2; + } + + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + { + public short e0; + } + + [InlineArray(4)] + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Latest.cs new file mode 100644 index 00000000..b31e1091 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Latest.cs @@ -0,0 +1,155 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + public partial struct MyStruct + { + public short x; + + public short y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref short z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + return ref Anonymous.w; + } + } + + [UnscopedRef] + public ref short value1 + { + get + { + return ref Anonymous.Anonymous1.value1; + } + } + + [UnscopedRef] + public ref short value + { + get + { + return ref Anonymous.Anonymous1.Anonymous.value; + } + } + + [UnscopedRef] + public ref short value2 + { + get + { + return ref Anonymous.Anonymous2.value2; + } + } + + [UnscopedRef] + public ref MyUnion u + { + get + { + return ref Anonymous.u; + } + } + + [UnscopedRef] + public Span buffer1 + { + get + { + return Anonymous.buffer1; + } + } + + [UnscopedRef] + public Span buffer2 + { + get + { + return Anonymous.buffer2; + } + } + + public partial struct _Anonymous_e__Struct + { + public short z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("short[4]")] + public _buffer1_e__FixedBuffer buffer1; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public short value; + } + + public partial struct _Anonymous1_e__Struct + { + public short value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public short value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public short value2; + } + + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + { + public short e0; + } + + [InlineArray(4)] + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Preview.cs new file mode 100644 index 00000000..b31e1091 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.CSharp.Preview.cs @@ -0,0 +1,155 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + public partial struct MyStruct + { + public short x; + + public short y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref short z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._w_e__Struct w + { + get + { + return ref Anonymous.w; + } + } + + [UnscopedRef] + public ref short value1 + { + get + { + return ref Anonymous.Anonymous1.value1; + } + } + + [UnscopedRef] + public ref short value + { + get + { + return ref Anonymous.Anonymous1.Anonymous.value; + } + } + + [UnscopedRef] + public ref short value2 + { + get + { + return ref Anonymous.Anonymous2.value2; + } + } + + [UnscopedRef] + public ref MyUnion u + { + get + { + return ref Anonymous.u; + } + } + + [UnscopedRef] + public Span buffer1 + { + get + { + return Anonymous.buffer1; + } + } + + [UnscopedRef] + public Span buffer2 + { + get + { + return Anonymous.buffer2; + } + } + + public partial struct _Anonymous_e__Struct + { + public short z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C9")] + public _w_e__Struct w; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L19_C9")] + public _Anonymous1_e__Struct Anonymous1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L29_C9")] + public _Anonymous2_e__Union Anonymous2; + + public MyUnion u; + + [NativeTypeName("short[4]")] + public _buffer1_e__FixedBuffer buffer1; + + [NativeTypeName("MyUnion[4]")] + public _buffer2_e__FixedBuffer buffer2; + + public partial struct _w_e__Struct + { + public short value; + } + + public partial struct _Anonymous1_e__Struct + { + public short value1; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L23_C13")] + public _Anonymous_e__Struct Anonymous; + + public partial struct _Anonymous_e__Struct + { + public short value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous2_e__Union + { + [FieldOffset(0)] + public short value2; + } + + [InlineArray(4)] + public partial struct _buffer1_e__FixedBuffer + { + public short e0; + } + + [InlineArray(4)] + public partial struct _buffer2_e__FixedBuffer + { + public MyUnion e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Compatible.xml new file mode 100644 index 00000000..16472978 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Compatible.xml @@ -0,0 +1,165 @@ + + + + + + short + + + + + short + + + short + + + _Anonymous_e__Struct + + + ref short + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->z; + } + + + + ref _Anonymous_e__Struct._w_e__Struct + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->w; + } + + + + ref short + + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) + { + return ref pField->value1; + } + + + + ref short + + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous_e__Struct* pField = &Anonymous.Anonymous1.Anonymous) + { + return ref pField->value; + } + + + + ref short + + fixed (_Anonymous_e__Struct._Anonymous2_e__Union* pField = &Anonymous.Anonymous2) + { + return ref pField->value2; + } + + + + ref MyUnion + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->u; + } + + + + ref short + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer1[0]; + } + + + + ref _Anonymous_e__Struct._buffer2_e__FixedBuffer + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->buffer2; + } + + + + + short + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + short + + + MyUnion + + + + short + + + + + short + + + _Anonymous_e__Struct + + + + short + + + + + + short + + + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Default.xml new file mode 100644 index 00000000..a2e31106 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Default.xml @@ -0,0 +1,127 @@ + + + + + + short + + + + + short + + + short + + + _Anonymous_e__Struct + + + ref short + + return ref Anonymous.z; + + + + ref _Anonymous_e__Struct._w_e__Struct + + return ref Anonymous.w; + + + + ref short + + return ref Anonymous.Anonymous1.value1; + + + + ref short + + return ref Anonymous.Anonymous1.Anonymous.value; + + + + ref short + + return ref Anonymous.Anonymous2.value2; + + + + ref MyUnion + + return ref Anonymous.u; + + + + Span<short> + + return Anonymous.buffer1; + + + + Span<MyUnion> + + return Anonymous.buffer2; + + + + + short + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + short + + + MyUnion + + + + short + + + + + short + + + _Anonymous_e__Struct + + + + short + + + + + + short + + + + InlineArray(4) + + short + + + + InlineArray(4) + + MyUnion + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Latest.xml new file mode 100644 index 00000000..a2e31106 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Latest.xml @@ -0,0 +1,127 @@ + + + + + + short + + + + + short + + + short + + + _Anonymous_e__Struct + + + ref short + + return ref Anonymous.z; + + + + ref _Anonymous_e__Struct._w_e__Struct + + return ref Anonymous.w; + + + + ref short + + return ref Anonymous.Anonymous1.value1; + + + + ref short + + return ref Anonymous.Anonymous1.Anonymous.value; + + + + ref short + + return ref Anonymous.Anonymous2.value2; + + + + ref MyUnion + + return ref Anonymous.u; + + + + Span<short> + + return Anonymous.buffer1; + + + + Span<MyUnion> + + return Anonymous.buffer2; + + + + + short + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + short + + + MyUnion + + + + short + + + + + short + + + _Anonymous_e__Struct + + + + short + + + + + + short + + + + InlineArray(4) + + short + + + + InlineArray(4) + + MyUnion + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Preview.xml new file mode 100644 index 00000000..a2e31106 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousTest_short_5Fshort_5F10_5F5.Xml.Preview.xml @@ -0,0 +1,127 @@ + + + + + + short + + + + + short + + + short + + + _Anonymous_e__Struct + + + ref short + + return ref Anonymous.z; + + + + ref _Anonymous_e__Struct._w_e__Struct + + return ref Anonymous.w; + + + + ref short + + return ref Anonymous.Anonymous1.value1; + + + + ref short + + return ref Anonymous.Anonymous1.Anonymous.value; + + + + ref short + + return ref Anonymous.Anonymous2.value2; + + + + ref MyUnion + + return ref Anonymous.u; + + + + Span<short> + + return Anonymous.buffer1; + + + + Span<MyUnion> + + return Anonymous.buffer2; + + + + + short + + + _w_e__Struct + + + _Anonymous1_e__Struct + + + _Anonymous2_e__Union + + + MyUnion + + + short + + + MyUnion + + + + short + + + + + short + + + _Anonymous_e__Struct + + + + short + + + + + + short + + + + InlineArray(4) + + short + + + + InlineArray(4) + + MyUnion + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Compatible.cs new file mode 100644 index 00000000..a5c7f6d5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Compatible.cs @@ -0,0 +1,103 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public int x; + + public int y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L6_C5")] + public _Anonymous_e__Struct Anonymous; + + public ref int z + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->z; + } + } + } + + public ref int w + { + get + { + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) + { + return ref pField->w; + } + } + } + + public int o0_b0_16 + { + get + { + return Anonymous.Anonymous1.o0_b0_16; + } + + set + { + Anonymous.Anonymous1.o0_b0_16 = value; + } + } + + public int o0_b16_4 + { + get + { + return Anonymous.Anonymous1.o0_b16_4; + } + + set + { + Anonymous.Anonymous1.o0_b16_4 = value; + } + } + + public unsafe partial struct _Anonymous_e__Struct + { + public int z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C9")] + public _Anonymous1_e__Struct Anonymous1; + + public partial struct _Anonymous1_e__Struct + { + public int w; + + public int _bitfield; + + [NativeTypeName("int : 16")] + public int o0_b0_16 + { + get + { + return (_bitfield << 16) >> 16; + } + + set + { + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + } + } + + [NativeTypeName("int : 4")] + public int o0_b16_4 + { + get + { + return (_bitfield << 12) >> 28; + } + + set + { + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Default.cs new file mode 100644 index 00000000..22edc69c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Default.cs @@ -0,0 +1,101 @@ +using System.Diagnostics.CodeAnalysis; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int x; + + public int y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L6_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref int w + { + get + { + return ref Anonymous.Anonymous1.w; + } + } + + public int o0_b0_16 + { + readonly get + { + return Anonymous.Anonymous1.o0_b0_16; + } + + set + { + Anonymous.Anonymous1.o0_b0_16 = value; + } + } + + public int o0_b16_4 + { + readonly get + { + return Anonymous.Anonymous1.o0_b16_4; + } + + set + { + Anonymous.Anonymous1.o0_b16_4 = value; + } + } + + public partial struct _Anonymous_e__Struct + { + public int z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C9")] + public _Anonymous1_e__Struct Anonymous1; + + public partial struct _Anonymous1_e__Struct + { + public int w; + + public int _bitfield; + + [NativeTypeName("int : 16")] + public int o0_b0_16 + { + readonly get + { + return (_bitfield << 16) >> 16; + } + + set + { + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + } + } + + [NativeTypeName("int : 4")] + public int o0_b16_4 + { + readonly get + { + return (_bitfield << 12) >> 28; + } + + set + { + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Latest.cs new file mode 100644 index 00000000..22edc69c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Latest.cs @@ -0,0 +1,101 @@ +using System.Diagnostics.CodeAnalysis; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int x; + + public int y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L6_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref int w + { + get + { + return ref Anonymous.Anonymous1.w; + } + } + + public int o0_b0_16 + { + readonly get + { + return Anonymous.Anonymous1.o0_b0_16; + } + + set + { + Anonymous.Anonymous1.o0_b0_16 = value; + } + } + + public int o0_b16_4 + { + readonly get + { + return Anonymous.Anonymous1.o0_b16_4; + } + + set + { + Anonymous.Anonymous1.o0_b16_4 = value; + } + } + + public partial struct _Anonymous_e__Struct + { + public int z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C9")] + public _Anonymous1_e__Struct Anonymous1; + + public partial struct _Anonymous1_e__Struct + { + public int w; + + public int _bitfield; + + [NativeTypeName("int : 16")] + public int o0_b0_16 + { + readonly get + { + return (_bitfield << 16) >> 16; + } + + set + { + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + } + } + + [NativeTypeName("int : 4")] + public int o0_b16_4 + { + readonly get + { + return (_bitfield << 12) >> 28; + } + + set + { + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Preview.cs new file mode 100644 index 00000000..22edc69c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Preview.cs @@ -0,0 +1,101 @@ +using System.Diagnostics.CodeAnalysis; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int x; + + public int y; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L6_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref int w + { + get + { + return ref Anonymous.Anonymous1.w; + } + } + + public int o0_b0_16 + { + readonly get + { + return Anonymous.Anonymous1.o0_b0_16; + } + + set + { + Anonymous.Anonymous1.o0_b0_16 = value; + } + } + + public int o0_b16_4 + { + readonly get + { + return Anonymous.Anonymous1.o0_b16_4; + } + + set + { + Anonymous.Anonymous1.o0_b16_4 = value; + } + } + + public partial struct _Anonymous_e__Struct + { + public int z; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C9")] + public _Anonymous1_e__Struct Anonymous1; + + public partial struct _Anonymous1_e__Struct + { + public int w; + + public int _bitfield; + + [NativeTypeName("int : 16")] + public int o0_b0_16 + { + readonly get + { + return (_bitfield << 16) >> 16; + } + + set + { + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + } + } + + [NativeTypeName("int : 4")] + public int o0_b16_4 + { + readonly get + { + return (_bitfield << 12) >> 28; + } + + set + { + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Compatible.xml new file mode 100644 index 00000000..be53c945 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Compatible.xml @@ -0,0 +1,88 @@ + + + + + + int + + + int + + + _Anonymous_e__Struct + + + ref int + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->z; + } + + + + ref int + + fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) + { + return ref pField->w; + } + + + + int + + return Anonymous.Anonymous1.o0_b0_16; + + + Anonymous.Anonymous1.o0_b0_16 = value; + + + + int + + return Anonymous.Anonymous1.o0_b16_4; + + + Anonymous.Anonymous1.o0_b16_4 = value; + + + + + int + + + _Anonymous1_e__Struct + + + + int + + + int + + + int + + return (_bitfield << 16) >> 16; + + + + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + + + + int + + return (_bitfield << 12) >> 28; + + + + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Default.xml new file mode 100644 index 00000000..d2a1ad2a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Default.xml @@ -0,0 +1,82 @@ + + + + + + int + + + int + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.z; + + + + ref int + + return ref Anonymous.Anonymous1.w; + + + + int + + return Anonymous.Anonymous1.o0_b0_16; + + + Anonymous.Anonymous1.o0_b0_16 = value; + + + + int + + return Anonymous.Anonymous1.o0_b16_4; + + + Anonymous.Anonymous1.o0_b16_4 = value; + + + + + int + + + _Anonymous1_e__Struct + + + + int + + + int + + + int + + return (_bitfield << 16) >> 16; + + + + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + + + + int + + return (_bitfield << 12) >> 28; + + + + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Latest.xml new file mode 100644 index 00000000..d2a1ad2a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Latest.xml @@ -0,0 +1,82 @@ + + + + + + int + + + int + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.z; + + + + ref int + + return ref Anonymous.Anonymous1.w; + + + + int + + return Anonymous.Anonymous1.o0_b0_16; + + + Anonymous.Anonymous1.o0_b0_16 = value; + + + + int + + return Anonymous.Anonymous1.o0_b16_4; + + + Anonymous.Anonymous1.o0_b16_4 = value; + + + + + int + + + _Anonymous1_e__Struct + + + + int + + + int + + + int + + return (_bitfield << 16) >> 16; + + + + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + + + + int + + return (_bitfield << 12) >> 28; + + + + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Preview.xml new file mode 100644 index 00000000..d2a1ad2a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedAnonymousWithBitfieldTest.Xml.Preview.xml @@ -0,0 +1,82 @@ + + + + + + int + + + int + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.z; + + + + ref int + + return ref Anonymous.Anonymous1.w; + + + + int + + return Anonymous.Anonymous1.o0_b0_16; + + + Anonymous.Anonymous1.o0_b0_16 = value; + + + + int + + return Anonymous.Anonymous1.o0_b16_4; + + + Anonymous.Anonymous1.o0_b16_4 = value; + + + + + int + + + _Anonymous1_e__Struct + + + + int + + + int + + + int + + return (_bitfield << 16) >> 16; + + + + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + + + + int + + return (_bitfield << 12) >> 28; + + + + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_double_5Fdouble.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_double_5Fdouble.CSharp.cs new file mode 100644 index 00000000..0cb50df0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_double_5Fdouble.CSharp.cs @@ -0,0 +1,22 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double r; + + public double g; + + public double b; + + public partial struct MyNestedStruct + { + public double r; + + public double g; + + public double b; + + public double a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_double_5Fdouble.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_double_5Fdouble.Xml.xml new file mode 100644 index 00000000..8672ce0a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_double_5Fdouble.Xml.xml @@ -0,0 +1,30 @@ + + + + + + double + + + double + + + double + + + + double + + + double + + + double + + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_float_5Ffloat.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_float_5Ffloat.CSharp.cs new file mode 100644 index 00000000..0f24586d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_float_5Ffloat.CSharp.cs @@ -0,0 +1,22 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float r; + + public float g; + + public float b; + + public partial struct MyNestedStruct + { + public float r; + + public float g; + + public float b; + + public float a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_float_5Ffloat.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_float_5Ffloat.Xml.xml new file mode 100644 index 00000000..b7251916 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_float_5Ffloat.Xml.xml @@ -0,0 +1,30 @@ + + + + + + float + + + float + + + float + + + + float + + + float + + + float + + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_int_5Fint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_int_5Fint.CSharp.cs new file mode 100644 index 00000000..c0723de1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_int_5Fint.CSharp.cs @@ -0,0 +1,22 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int r; + + public int g; + + public int b; + + public partial struct MyNestedStruct + { + public int r; + + public int g; + + public int b; + + public int a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_int_5Fint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_int_5Fint.Xml.xml new file mode 100644 index 00000000..a93f89d6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_int_5Fint.Xml.xml @@ -0,0 +1,30 @@ + + + + + + int + + + int + + + int + + + + int + + + int + + + int + + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_short_5Fshort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_short_5Fshort.CSharp.cs new file mode 100644 index 00000000..00a0b246 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_short_5Fshort.CSharp.cs @@ -0,0 +1,22 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short r; + + public short g; + + public short b; + + public partial struct MyNestedStruct + { + public short r; + + public short g; + + public short b; + + public short a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_short_5Fshort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_short_5Fshort.Xml.xml new file mode 100644 index 00000000..79228db5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedTest_short_5Fshort.Xml.xml @@ -0,0 +1,30 @@ + + + + + + short + + + short + + + short + + + + short + + + short + + + short + + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs new file mode 100644 index 00000000..f2ef4c84 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs @@ -0,0 +1,29 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("bool")] + public byte r; + + [NativeTypeName("bool")] + public byte g; + + [NativeTypeName("bool")] + public byte b; + + public partial struct MyNestedStruct + { + [NativeTypeName("bool")] + public byte r; + + [NativeTypeName("bool")] + public byte g; + + [NativeTypeName("bool")] + public byte b; + + [NativeTypeName("bool")] + public byte a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.Xml.xml new file mode 100644 index 00000000..6a9f2e89 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.Xml.xml @@ -0,0 +1,30 @@ + + + + + + byte + + + byte + + + byte + + + + byte + + + byte + + + byte + + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs new file mode 100644 index 00000000..aeed502a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs @@ -0,0 +1,29 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("long long")] + public long r; + + [NativeTypeName("long long")] + public long g; + + [NativeTypeName("long long")] + public long b; + + public partial struct MyNestedStruct + { + [NativeTypeName("long long")] + public long r; + + [NativeTypeName("long long")] + public long g; + + [NativeTypeName("long long")] + public long b; + + [NativeTypeName("long long")] + public long a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.Xml.xml new file mode 100644 index 00000000..8e5592f9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.Xml.xml @@ -0,0 +1,30 @@ + + + + + + long + + + long + + + long + + + + long + + + long + + + long + + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs new file mode 100644 index 00000000..4643558b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs @@ -0,0 +1,29 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("signed char")] + public sbyte r; + + [NativeTypeName("signed char")] + public sbyte g; + + [NativeTypeName("signed char")] + public sbyte b; + + public partial struct MyNestedStruct + { + [NativeTypeName("signed char")] + public sbyte r; + + [NativeTypeName("signed char")] + public sbyte g; + + [NativeTypeName("signed char")] + public sbyte b; + + [NativeTypeName("signed char")] + public sbyte a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml new file mode 100644 index 00000000..a27f86f2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml @@ -0,0 +1,30 @@ + + + + + + sbyte + + + sbyte + + + sbyte + + + + sbyte + + + sbyte + + + sbyte + + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs new file mode 100644 index 00000000..7a1e283b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs @@ -0,0 +1,29 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned char")] + public byte r; + + [NativeTypeName("unsigned char")] + public byte g; + + [NativeTypeName("unsigned char")] + public byte b; + + public partial struct MyNestedStruct + { + [NativeTypeName("unsigned char")] + public byte r; + + [NativeTypeName("unsigned char")] + public byte g; + + [NativeTypeName("unsigned char")] + public byte b; + + [NativeTypeName("unsigned char")] + public byte a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml new file mode 100644 index 00000000..62264b8c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml @@ -0,0 +1,30 @@ + + + + + + byte + + + byte + + + byte + + + + byte + + + byte + + + byte + + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs new file mode 100644 index 00000000..5bad1ccb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs @@ -0,0 +1,29 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned int")] + public uint r; + + [NativeTypeName("unsigned int")] + public uint g; + + [NativeTypeName("unsigned int")] + public uint b; + + public partial struct MyNestedStruct + { + [NativeTypeName("unsigned int")] + public uint r; + + [NativeTypeName("unsigned int")] + public uint g; + + [NativeTypeName("unsigned int")] + public uint b; + + [NativeTypeName("unsigned int")] + public uint a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml new file mode 100644 index 00000000..55fbc543 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml @@ -0,0 +1,30 @@ + + + + + + uint + + + uint + + + uint + + + + uint + + + uint + + + uint + + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs new file mode 100644 index 00000000..843e7437 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs @@ -0,0 +1,29 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned long long")] + public ulong r; + + [NativeTypeName("unsigned long long")] + public ulong g; + + [NativeTypeName("unsigned long long")] + public ulong b; + + public partial struct MyNestedStruct + { + [NativeTypeName("unsigned long long")] + public ulong r; + + [NativeTypeName("unsigned long long")] + public ulong g; + + [NativeTypeName("unsigned long long")] + public ulong b; + + [NativeTypeName("unsigned long long")] + public ulong a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml new file mode 100644 index 00000000..65261b85 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml @@ -0,0 +1,30 @@ + + + + + + ulong + + + ulong + + + ulong + + + + ulong + + + ulong + + + ulong + + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs new file mode 100644 index 00000000..63d7f1e0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs @@ -0,0 +1,29 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned short")] + public ushort r; + + [NativeTypeName("unsigned short")] + public ushort g; + + [NativeTypeName("unsigned short")] + public ushort b; + + public partial struct MyNestedStruct + { + [NativeTypeName("unsigned short")] + public ushort r; + + [NativeTypeName("unsigned short")] + public ushort g; + + [NativeTypeName("unsigned short")] + public ushort b; + + [NativeTypeName("unsigned short")] + public ushort a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml new file mode 100644 index 00000000..eb513bd1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml @@ -0,0 +1,30 @@ + + + + + + ushort + + + ushort + + + ushort + + + + ushort + + + ushort + + + ushort + + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NewKeywordTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NewKeywordTest.CSharp.cs new file mode 100644 index 00000000..268fbc52 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NewKeywordTest.CSharp.cs @@ -0,0 +1,19 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public new int Equals; + + public int Dispose; + + public new int GetHashCode; + + public new int GetType; + + public new int MemberwiseClone; + + public new int ReferenceEquals; + + public new int ToString; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NewKeywordTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NewKeywordTest.Xml.xml new file mode 100644 index 00000000..3ad7bec1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NewKeywordTest.Xml.xml @@ -0,0 +1,28 @@ + + + + + + int + + + int + + + int + + + int + + + int + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NoDefinitionTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NoDefinitionTest.CSharp.cs new file mode 100644 index 00000000..e82ea8f7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NoDefinitionTest.CSharp.cs @@ -0,0 +1,6 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NoDefinitionTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NoDefinitionTest.Xml.xml new file mode 100644 index 00000000..c71e9923 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/NoDefinitionTest.Xml.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PackTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PackTest.CSharp.cs new file mode 100644 index 00000000..eb72be11 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PackTest.CSharp.cs @@ -0,0 +1,27 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct1 + { + [NativeTypeName("unsigned int")] + public uint Field1; + + public void* Field2; + + [NativeTypeName("unsigned int")] + public uint Field3; + } + + [StructLayout(LayoutKind.Sequential, Pack = 4)] + public unsafe partial struct MyStruct2 + { + [NativeTypeName("unsigned int")] + public uint Field1; + + public void* Field2; + + [NativeTypeName("unsigned int")] + public uint Field3; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PackTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PackTest.Xml.xml new file mode 100644 index 00000000..5c56d36c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PackTest.Xml.xml @@ -0,0 +1,27 @@ + + + + + + uint + + + void* + + + uint + + + + + uint + + + void* + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfTest.CSharp.cs new file mode 100644 index 00000000..20c5b911 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfTest.CSharp.cs @@ -0,0 +1,9 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct example_s + { + public example_s* next; + + public void* data; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfTest.Xml.xml new file mode 100644 index 00000000..fb82329b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfTest.Xml.xml @@ -0,0 +1,13 @@ + + + + + + example_s* + + + void* + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfViaTypedefTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfViaTypedefTest.CSharp.cs new file mode 100644 index 00000000..d5808dba --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfViaTypedefTest.CSharp.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct example_s + { + [NativeTypeName("example_t *")] + public example_s* next; + + public void* data; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfViaTypedefTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfViaTypedefTest.Xml.xml new file mode 100644 index 00000000..383d5ee7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/PointerToSelfViaTypedefTest.Xml.xml @@ -0,0 +1,13 @@ + + + + + + example_s* + + + void* + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Compatible.cs new file mode 100644 index 00000000..f96a212d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Compatible.cs @@ -0,0 +1,30 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public double r; + + public double g; + + public double b; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C5")] + public _Anonymous_e__Struct Anonymous; + + public ref double a + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->a; + } + } + } + + public partial struct _Anonymous_e__Struct + { + public double a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Default.cs new file mode 100644 index 00000000..0cae780e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Default.cs @@ -0,0 +1,30 @@ +using System.Diagnostics.CodeAnalysis; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double r; + + public double g; + + public double b; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref double a + { + get + { + return ref Anonymous.a; + } + } + + public partial struct _Anonymous_e__Struct + { + public double a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Latest.cs new file mode 100644 index 00000000..0cae780e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Latest.cs @@ -0,0 +1,30 @@ +using System.Diagnostics.CodeAnalysis; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double r; + + public double g; + + public double b; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref double a + { + get + { + return ref Anonymous.a; + } + } + + public partial struct _Anonymous_e__Struct + { + public double a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Preview.cs new file mode 100644 index 00000000..0cae780e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.CSharp.Preview.cs @@ -0,0 +1,30 @@ +using System.Diagnostics.CodeAnalysis; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double r; + + public double g; + + public double b; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref double a + { + get + { + return ref Anonymous.a; + } + } + + public partial struct _Anonymous_e__Struct + { + public double a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Compatible.xml new file mode 100644 index 00000000..17842151 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Compatible.xml @@ -0,0 +1,33 @@ + + + + + + double + + + double + + + double + + + _Anonymous_e__Struct + + + ref double + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->a; + } + + + + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Default.xml new file mode 100644 index 00000000..fc65fe70 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Default.xml @@ -0,0 +1,30 @@ + + + + + + double + + + double + + + double + + + _Anonymous_e__Struct + + + ref double + + return ref Anonymous.a; + + + + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Latest.xml new file mode 100644 index 00000000..fc65fe70 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Latest.xml @@ -0,0 +1,30 @@ + + + + + + double + + + double + + + double + + + _Anonymous_e__Struct + + + ref double + + return ref Anonymous.a; + + + + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Preview.xml new file mode 100644 index 00000000..fc65fe70 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapNestedAnonymousTest.Xml.Preview.xml @@ -0,0 +1,30 @@ + + + + + + double + + + double + + + double + + + _Anonymous_e__Struct + + + ref double + + return ref Anonymous.a; + + + + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapTest.CSharp.cs new file mode 100644 index 00000000..e82ea8f7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapTest.CSharp.cs @@ -0,0 +1,6 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapTest.Xml.xml new file mode 100644 index 00000000..c71e9923 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/RemapTest.Xml.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionPointerTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionPointerTest.CSharp.cs new file mode 100644 index 00000000..e82ea8f7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionPointerTest.CSharp.cs @@ -0,0 +1,6 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionPointerTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionPointerTest.Xml.xml new file mode 100644 index 00000000..c71e9923 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionPointerTest.Xml.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_double_5Fdouble.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_double_5Fdouble.CSharp.cs new file mode 100644 index 00000000..5ae4f8fe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_double_5Fdouble.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double r; + + public double g; + + public double b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_double_5Fdouble.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_double_5Fdouble.Xml.xml new file mode 100644 index 00000000..5077cd83 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_double_5Fdouble.Xml.xml @@ -0,0 +1,16 @@ + + + + + + double + + + double + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_float_5Ffloat.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_float_5Ffloat.CSharp.cs new file mode 100644 index 00000000..af54b381 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_float_5Ffloat.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float r; + + public float g; + + public float b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_float_5Ffloat.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_float_5Ffloat.Xml.xml new file mode 100644 index 00000000..374ff19a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_float_5Ffloat.Xml.xml @@ -0,0 +1,16 @@ + + + + + + float + + + float + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_int_5Fint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_int_5Fint.CSharp.cs new file mode 100644 index 00000000..30d6c633 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_int_5Fint.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int r; + + public int g; + + public int b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_int_5Fint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_int_5Fint.Xml.xml new file mode 100644 index 00000000..27257476 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_int_5Fint.Xml.xml @@ -0,0 +1,16 @@ + + + + + + int + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_short_5Fshort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_short_5Fshort.CSharp.cs new file mode 100644 index 00000000..eb6aff08 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_short_5Fshort.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short r; + + public short g; + + public short b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_short_5Fshort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_short_5Fshort.Xml.xml new file mode 100644 index 00000000..bbd27e31 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionTest_short_5Fshort.Xml.xml @@ -0,0 +1,16 @@ + + + + + + short + + + short + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs new file mode 100644 index 00000000..2459a799 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("bool")] + public byte r; + + [NativeTypeName("bool")] + public byte g; + + [NativeTypeName("bool")] + public byte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.Xml.xml new file mode 100644 index 00000000..2efd5005 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + byte + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs new file mode 100644 index 00000000..b7fe72ca --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("long long")] + public long r; + + [NativeTypeName("long long")] + public long g; + + [NativeTypeName("long long")] + public long b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.Xml.xml new file mode 100644 index 00000000..510adc82 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.Xml.xml @@ -0,0 +1,16 @@ + + + + + + long + + + long + + + long + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs new file mode 100644 index 00000000..76c52d3c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("signed char")] + public sbyte r; + + [NativeTypeName("signed char")] + public sbyte g; + + [NativeTypeName("signed char")] + public sbyte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml new file mode 100644 index 00000000..ef4a07bf --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + sbyte + + + sbyte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs new file mode 100644 index 00000000..efea8ec7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned char")] + public byte r; + + [NativeTypeName("unsigned char")] + public byte g; + + [NativeTypeName("unsigned char")] + public byte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml new file mode 100644 index 00000000..9dbe4132 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + byte + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs new file mode 100644 index 00000000..6bced97f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned int")] + public uint r; + + [NativeTypeName("unsigned int")] + public uint g; + + [NativeTypeName("unsigned int")] + public uint b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml new file mode 100644 index 00000000..0e7bdb22 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + uint + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs new file mode 100644 index 00000000..4b6da458 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned long long")] + public ulong r; + + [NativeTypeName("unsigned long long")] + public ulong g; + + [NativeTypeName("unsigned long long")] + public ulong b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml new file mode 100644 index 00000000..e8cfdc96 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + ulong + + + ulong + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs new file mode 100644 index 00000000..91e4bec0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("unsigned short")] + public ushort r; + + [NativeTypeName("unsigned short")] + public ushort g; + + [NativeTypeName("unsigned short")] + public ushort b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml new file mode 100644 index 00000000..207d533d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + ushort + + + ushort + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SourceLocationAttributeTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SourceLocationAttributeTest.CSharp.cs new file mode 100644 index 00000000..00f49ab9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SourceLocationAttributeTest.CSharp.cs @@ -0,0 +1,15 @@ +namespace ClangSharp.Test +{ + [SourceLocation("ClangUnsavedFile.h", 1, 8)] + public partial struct MyStruct + { + [SourceLocation("ClangUnsavedFile.h", 3, 9)] + public int r; + + [SourceLocation("ClangUnsavedFile.h", 4, 9)] + public int g; + + [SourceLocation("ClangUnsavedFile.h", 5, 9)] + public int b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SourceLocationAttributeTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SourceLocationAttributeTest.Xml.xml new file mode 100644 index 00000000..27257476 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/SourceLocationAttributeTest.Xml.xml @@ -0,0 +1,16 @@ + + + + + + int + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_bool_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_bool_5Fbyte.CSharp.cs new file mode 100644 index 00000000..1b869c55 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_bool_5Fbyte.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyTypedefAlias")] + public byte r; + + [NativeTypeName("MyTypedefAlias")] + public byte g; + + [NativeTypeName("MyTypedefAlias")] + public byte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_bool_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_bool_5Fbyte.Xml.xml new file mode 100644 index 00000000..e1d86744 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_bool_5Fbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + byte + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_double_5Fdouble.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_double_5Fdouble.CSharp.cs new file mode 100644 index 00000000..2e7f1255 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_double_5Fdouble.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyTypedefAlias")] + public double r; + + [NativeTypeName("MyTypedefAlias")] + public double g; + + [NativeTypeName("MyTypedefAlias")] + public double b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_double_5Fdouble.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_double_5Fdouble.Xml.xml new file mode 100644 index 00000000..b9487771 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_double_5Fdouble.Xml.xml @@ -0,0 +1,16 @@ + + + + + + double + + + double + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_float_5Ffloat.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_float_5Ffloat.CSharp.cs new file mode 100644 index 00000000..ec433d1c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_float_5Ffloat.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyTypedefAlias")] + public float r; + + [NativeTypeName("MyTypedefAlias")] + public float g; + + [NativeTypeName("MyTypedefAlias")] + public float b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_float_5Ffloat.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_float_5Ffloat.Xml.xml new file mode 100644 index 00000000..46893195 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_float_5Ffloat.Xml.xml @@ -0,0 +1,16 @@ + + + + + + float + + + float + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_int_5Fint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_int_5Fint.CSharp.cs new file mode 100644 index 00000000..ce830e39 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_int_5Fint.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyTypedefAlias")] + public int r; + + [NativeTypeName("MyTypedefAlias")] + public int g; + + [NativeTypeName("MyTypedefAlias")] + public int b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_int_5Fint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_int_5Fint.Xml.xml new file mode 100644 index 00000000..00c2a638 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_int_5Fint.Xml.xml @@ -0,0 +1,16 @@ + + + + + + int + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_long_20long_5Flong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_long_20long_5Flong.CSharp.cs new file mode 100644 index 00000000..a1befffe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_long_20long_5Flong.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyTypedefAlias")] + public long r; + + [NativeTypeName("MyTypedefAlias")] + public long g; + + [NativeTypeName("MyTypedefAlias")] + public long b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_long_20long_5Flong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_long_20long_5Flong.Xml.xml new file mode 100644 index 00000000..059eac1b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_long_20long_5Flong.Xml.xml @@ -0,0 +1,16 @@ + + + + + + long + + + long + + + long + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_short_5Fshort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_short_5Fshort.CSharp.cs new file mode 100644 index 00000000..66d5e77f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_short_5Fshort.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyTypedefAlias")] + public short r; + + [NativeTypeName("MyTypedefAlias")] + public short g; + + [NativeTypeName("MyTypedefAlias")] + public short b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_short_5Fshort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_short_5Fshort.Xml.xml new file mode 100644 index 00000000..6a9c6061 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_short_5Fshort.Xml.xml @@ -0,0 +1,16 @@ + + + + + + short + + + short + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_signed_20char_5Fsbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_signed_20char_5Fsbyte.CSharp.cs new file mode 100644 index 00000000..0d4c8f49 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_signed_20char_5Fsbyte.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyTypedefAlias")] + public sbyte r; + + [NativeTypeName("MyTypedefAlias")] + public sbyte g; + + [NativeTypeName("MyTypedefAlias")] + public sbyte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_signed_20char_5Fsbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_signed_20char_5Fsbyte.Xml.xml new file mode 100644 index 00000000..94144e5d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_signed_20char_5Fsbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + sbyte + + + sbyte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20char_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20char_5Fbyte.CSharp.cs new file mode 100644 index 00000000..1b869c55 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20char_5Fbyte.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyTypedefAlias")] + public byte r; + + [NativeTypeName("MyTypedefAlias")] + public byte g; + + [NativeTypeName("MyTypedefAlias")] + public byte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20char_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20char_5Fbyte.Xml.xml new file mode 100644 index 00000000..e1d86744 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20char_5Fbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + byte + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20int_5Fuint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20int_5Fuint.CSharp.cs new file mode 100644 index 00000000..89dce023 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20int_5Fuint.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyTypedefAlias")] + public uint r; + + [NativeTypeName("MyTypedefAlias")] + public uint g; + + [NativeTypeName("MyTypedefAlias")] + public uint b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20int_5Fuint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20int_5Fuint.Xml.xml new file mode 100644 index 00000000..de4a5ff6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20int_5Fuint.Xml.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + uint + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.CSharp.cs new file mode 100644 index 00000000..8e49a258 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyTypedefAlias")] + public ulong r; + + [NativeTypeName("MyTypedefAlias")] + public ulong g; + + [NativeTypeName("MyTypedefAlias")] + public ulong b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.Xml.xml new file mode 100644 index 00000000..eb3265b7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.Xml.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + ulong + + + ulong + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20short_5Fushort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20short_5Fushort.CSharp.cs new file mode 100644 index 00000000..8560828a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20short_5Fushort.CSharp.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("MyTypedefAlias")] + public ushort r; + + [NativeTypeName("MyTypedefAlias")] + public ushort g; + + [NativeTypeName("MyTypedefAlias")] + public ushort b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20short_5Fushort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20short_5Fushort.Xml.xml new file mode 100644 index 00000000..431148e7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/TypedefTest_unsigned_20short_5Fushort.Xml.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + ushort + + + ushort + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/UsingDeclarationTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/UsingDeclarationTest.CSharp.cs new file mode 100644 index 00000000..ce35ed67 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/UsingDeclarationTest.CSharp.cs @@ -0,0 +1,17 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct1A + { + public void MyMethod() + { + } + } + + [NativeTypeName("struct MyStruct1B : MyStruct1A")] + public partial struct MyStruct1B + { + public void MyMethod() + { + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/UsingDeclarationTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/UsingDeclarationTest.Xml.xml new file mode 100644 index 00000000..0b7c19e7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/UsingDeclarationTest.Xml.xml @@ -0,0 +1,17 @@ + + + + + + void + + + + + + void + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithAccessSpecifierTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithAccessSpecifierTest.CSharp.cs new file mode 100644 index 00000000..009a2ae5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithAccessSpecifierTest.CSharp.cs @@ -0,0 +1,23 @@ +namespace ClangSharp.Test +{ + internal partial struct MyStruct1 + { + private int Field1; + + public int Field2; + } + + internal partial struct MyStruct2 + { + private int Field1; + + public int Field2; + } + + public partial struct MyStruct3 + { + private int Field1; + + internal int Field2; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithAccessSpecifierTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithAccessSpecifierTest.Xml.xml new file mode 100644 index 00000000..81f2baa9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithAccessSpecifierTest.Xml.xml @@ -0,0 +1,29 @@ + + + + + + int + + + int + + + + + int + + + int + + + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Compatible.cs new file mode 100644 index 00000000..7356faf9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Compatible.cs @@ -0,0 +1,29 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] + public partial struct MyStruct + { + [NativeTypeName("size_t[2]")] + public _FixedBuffer_e__FixedBuffer FixedBuffer; + + public partial struct _FixedBuffer_e__FixedBuffer + { + public UIntPtr e0; + public UIntPtr e1; + + public unsafe ref UIntPtr this[int index] + { + get + { + fixed (UIntPtr* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Default.cs new file mode 100644 index 00000000..582d798a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Default.cs @@ -0,0 +1,18 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] + public partial struct MyStruct + { + [NativeTypeName("size_t[2]")] + public _FixedBuffer_e__FixedBuffer FixedBuffer; + + [InlineArray(2)] + public partial struct _FixedBuffer_e__FixedBuffer + { + public nuint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Latest.cs new file mode 100644 index 00000000..582d798a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Latest.cs @@ -0,0 +1,18 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] + public partial struct MyStruct + { + [NativeTypeName("size_t[2]")] + public _FixedBuffer_e__FixedBuffer FixedBuffer; + + [InlineArray(2)] + public partial struct _FixedBuffer_e__FixedBuffer + { + public nuint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Preview.cs new file mode 100644 index 00000000..582d798a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.CSharp.Preview.cs @@ -0,0 +1,18 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] + public partial struct MyStruct + { + [NativeTypeName("size_t[2]")] + public _FixedBuffer_e__FixedBuffer FixedBuffer; + + [InlineArray(2)] + public partial struct _FixedBuffer_e__FixedBuffer + { + public nuint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Compatible.xml new file mode 100644 index 00000000..9fef18c6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Compatible.xml @@ -0,0 +1,30 @@ + + + + + + UIntPtr + + + + UIntPtr + + + UIntPtr + + + ref UIntPtr + + int + + + fixed (UIntPtr* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Default.xml new file mode 100644 index 00000000..8c8d33b6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + nuint + + + InlineArray(2) + + nuint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Latest.xml new file mode 100644 index 00000000..8c8d33b6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + nuint + + + InlineArray(2) + + nuint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Preview.xml new file mode 100644 index 00000000..8c8d33b6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StructDeclaration/WithPackingTest.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + nuint + + + InlineArray(2) + + nuint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_double_5Fdouble.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_double_5Fdouble.CSharp.cs new file mode 100644 index 00000000..992158fa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_double_5Fdouble.CSharp.cs @@ -0,0 +1,17 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double r; + + [FieldOffset(0)] + public double g; + + [FieldOffset(0)] + public double b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_double_5Fdouble.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_double_5Fdouble.Xml.xml new file mode 100644 index 00000000..35fcc2b6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_double_5Fdouble.Xml.xml @@ -0,0 +1,16 @@ + + + + + + double + + + double + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_float_5Ffloat.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_float_5Ffloat.CSharp.cs new file mode 100644 index 00000000..f08785b8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_float_5Ffloat.CSharp.cs @@ -0,0 +1,17 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float r; + + [FieldOffset(0)] + public float g; + + [FieldOffset(0)] + public float b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_float_5Ffloat.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_float_5Ffloat.Xml.xml new file mode 100644 index 00000000..9c2e176d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_float_5Ffloat.Xml.xml @@ -0,0 +1,16 @@ + + + + + + float + + + float + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_int_5Fint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_int_5Fint.CSharp.cs new file mode 100644 index 00000000..efdc9f8a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_int_5Fint.CSharp.cs @@ -0,0 +1,17 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int r; + + [FieldOffset(0)] + public int g; + + [FieldOffset(0)] + public int b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_int_5Fint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_int_5Fint.Xml.xml new file mode 100644 index 00000000..5d7c9ff3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_int_5Fint.Xml.xml @@ -0,0 +1,16 @@ + + + + + + int + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_short_5Fshort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_short_5Fshort.CSharp.cs new file mode 100644 index 00000000..e7369e88 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_short_5Fshort.CSharp.cs @@ -0,0 +1,17 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short r; + + [FieldOffset(0)] + public short g; + + [FieldOffset(0)] + public short b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_short_5Fshort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_short_5Fshort.Xml.xml new file mode 100644 index 00000000..11f5b08d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTestInCMode_short_5Fshort.Xml.xml @@ -0,0 +1,16 @@ + + + + + + short + + + short + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_double_5Fdouble.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_double_5Fdouble.CSharp.cs new file mode 100644 index 00000000..992158fa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_double_5Fdouble.CSharp.cs @@ -0,0 +1,17 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double r; + + [FieldOffset(0)] + public double g; + + [FieldOffset(0)] + public double b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_double_5Fdouble.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_double_5Fdouble.Xml.xml new file mode 100644 index 00000000..35fcc2b6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_double_5Fdouble.Xml.xml @@ -0,0 +1,16 @@ + + + + + + double + + + double + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_float_5Ffloat.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_float_5Ffloat.CSharp.cs new file mode 100644 index 00000000..f08785b8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_float_5Ffloat.CSharp.cs @@ -0,0 +1,17 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float r; + + [FieldOffset(0)] + public float g; + + [FieldOffset(0)] + public float b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_float_5Ffloat.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_float_5Ffloat.Xml.xml new file mode 100644 index 00000000..9c2e176d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_float_5Ffloat.Xml.xml @@ -0,0 +1,16 @@ + + + + + + float + + + float + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_int_5Fint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_int_5Fint.CSharp.cs new file mode 100644 index 00000000..efdc9f8a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_int_5Fint.CSharp.cs @@ -0,0 +1,17 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int r; + + [FieldOffset(0)] + public int g; + + [FieldOffset(0)] + public int b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_int_5Fint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_int_5Fint.Xml.xml new file mode 100644 index 00000000..5d7c9ff3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_int_5Fint.Xml.xml @@ -0,0 +1,16 @@ + + + + + + int + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_short_5Fshort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_short_5Fshort.CSharp.cs new file mode 100644 index 00000000..e7369e88 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_short_5Fshort.CSharp.cs @@ -0,0 +1,17 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short r; + + [FieldOffset(0)] + public short g; + + [FieldOffset(0)] + public short b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_short_5Fshort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_short_5Fshort.Xml.xml new file mode 100644 index 00000000..11f5b08d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicTest_short_5Fshort.Xml.xml @@ -0,0 +1,16 @@ + + + + + + short + + + short + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs new file mode 100644 index 00000000..83eef48e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte r; + + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte g; + + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.Xml.xml new file mode 100644 index 00000000..94027b07 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_bool_5Fbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + byte + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs new file mode 100644 index 00000000..7458cdde --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long")] + public long r; + + [FieldOffset(0)] + [NativeTypeName("long long")] + public long g; + + [FieldOffset(0)] + [NativeTypeName("long long")] + public long b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.Xml.xml new file mode 100644 index 00000000..478b8af8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_long_20long_5Flong.Xml.xml @@ -0,0 +1,16 @@ + + + + + + long + + + long + + + long + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs new file mode 100644 index 00000000..9f04efdb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte r; + + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte g; + + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml new file mode 100644 index 00000000..0b2b4a22 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + sbyte + + + sbyte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs new file mode 100644 index 00000000..2e955545 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte r; + + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte g; + + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml new file mode 100644 index 00000000..b6473799 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + byte + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs new file mode 100644 index 00000000..339b1f62 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint r; + + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint g; + + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml new file mode 100644 index 00000000..ac1fc227 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + uint + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs new file mode 100644 index 00000000..71b3faa2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong r; + + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong g; + + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml new file mode 100644 index 00000000..07911724 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + ulong + + + ulong + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs new file mode 100644 index 00000000..5b8b0295 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort r; + + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort g; + + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml new file mode 100644 index 00000000..7f601889 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BasicWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + ushort + + + ushort + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..e97bbc28 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,188 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion1 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + get + { + return (byte)((_bitfield2 >> 22) & 0x1u); + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + } + } + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + get + { + return (int)(_bitfield2 << 8) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + get + { + return (int)(_bitfield2 << 7) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion2 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + [FieldOffset(0)] + public int x; + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion3 + { + [FieldOffset(0)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..4aaa3479 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Compatible.Windows.cs @@ -0,0 +1,194 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit, Pack = 1)] + public partial struct MyUnion1 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [FieldOffset(0)] + public byte _bitfield3; + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + get + { + return (byte)(_bitfield3 & 0x1u); + } + + set + { + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + } + } + + [FieldOffset(0)] + public int _bitfield4; + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + get + { + return (_bitfield4 << 31) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + get + { + return (_bitfield4 << 30) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion2 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + [FieldOffset(0)] + public int x; + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + [StructLayout(LayoutKind.Explicit, Pack = 1)] + public partial struct MyUnion3 + { + [FieldOffset(0)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..255d735e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Default.Unix.cs @@ -0,0 +1,188 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion1 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)((_bitfield2 >> 22) & 0x1u); + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + } + } + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (int)(_bitfield2 << 8) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (int)(_bitfield2 << 7) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion2 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + [FieldOffset(0)] + public int x; + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion3 + { + [FieldOffset(0)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Default.Windows.cs new file mode 100644 index 00000000..8b79a58a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Default.Windows.cs @@ -0,0 +1,194 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit, Pack = 1)] + public partial struct MyUnion1 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [FieldOffset(0)] + public byte _bitfield3; + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)(_bitfield3 & 0x1u); + } + + set + { + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + } + } + + [FieldOffset(0)] + public int _bitfield4; + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (_bitfield4 << 31) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (_bitfield4 << 30) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion2 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + [FieldOffset(0)] + public int x; + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + [StructLayout(LayoutKind.Explicit, Pack = 1)] + public partial struct MyUnion3 + { + [FieldOffset(0)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..255d735e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Latest.Unix.cs @@ -0,0 +1,188 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion1 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)((_bitfield2 >> 22) & 0x1u); + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + } + } + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (int)(_bitfield2 << 8) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (int)(_bitfield2 << 7) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion2 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + [FieldOffset(0)] + public int x; + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion3 + { + [FieldOffset(0)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..8b79a58a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Latest.Windows.cs @@ -0,0 +1,194 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit, Pack = 1)] + public partial struct MyUnion1 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [FieldOffset(0)] + public byte _bitfield3; + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)(_bitfield3 & 0x1u); + } + + set + { + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + } + } + + [FieldOffset(0)] + public int _bitfield4; + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (_bitfield4 << 31) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (_bitfield4 << 30) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion2 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + [FieldOffset(0)] + public int x; + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + [StructLayout(LayoutKind.Explicit, Pack = 1)] + public partial struct MyUnion3 + { + [FieldOffset(0)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..255d735e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Preview.Unix.cs @@ -0,0 +1,188 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion1 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)((_bitfield2 >> 22) & 0x1u); + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + } + } + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (int)(_bitfield2 << 8) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (int)(_bitfield2 << 7) >> 31; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion2 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + [FieldOffset(0)] + public int x; + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion3 + { + [FieldOffset(0)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..8b79a58a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.CSharp.Preview.Windows.cs @@ -0,0 +1,194 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit, Pack = 1)] + public partial struct MyUnion1 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 24")] + public uint o0_b0_24 + { + readonly get + { + return _bitfield1 & 0xFFFFFFu; + } + + set + { + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + } + } + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 16")] + public uint o4_b0_16 + { + readonly get + { + return _bitfield2 & 0xFFFFu; + } + + set + { + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + } + } + + [NativeTypeName("unsigned int : 3")] + public uint o4_b16_3 + { + readonly get + { + return (_bitfield2 >> 16) & 0x7u; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + } + } + + [NativeTypeName("int : 3")] + public int o4_b19_3 + { + readonly get + { + return (int)(_bitfield2 << 10) >> 29; + } + + set + { + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + } + } + + [FieldOffset(0)] + public byte _bitfield3; + + [NativeTypeName("unsigned char : 1")] + public byte o8_b0_1 + { + readonly get + { + return (byte)(_bitfield3 & 0x1u); + } + + set + { + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + } + } + + [FieldOffset(0)] + public int _bitfield4; + + [NativeTypeName("int : 1")] + public int o12_b0_1 + { + readonly get + { + return (_bitfield4 << 31) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + } + } + + [NativeTypeName("int : 1")] + public int o12_b1_1 + { + readonly get + { + return (_bitfield4 << 30) >> 31; + } + + set + { + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion2 + { + [FieldOffset(0)] + public uint _bitfield1; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield1 & 0x1u; + } + + set + { + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + } + } + + [FieldOffset(0)] + public int x; + + [FieldOffset(0)] + public uint _bitfield2; + + [NativeTypeName("unsigned int : 1")] + public uint o8_b0_1 + { + readonly get + { + return _bitfield2 & 0x1u; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + } + } + } + + [StructLayout(LayoutKind.Explicit, Pack = 1)] + public partial struct MyUnion3 + { + [FieldOffset(0)] + public uint _bitfield; + + [NativeTypeName("unsigned int : 1")] + public uint o0_b0_1 + { + readonly get + { + return _bitfield & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + } + } + + [NativeTypeName("unsigned int : 1")] + public uint o0_b1_1 + { + readonly get + { + return (_bitfield >> 1) & 0x1u; + } + + set + { + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..ac72a129 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Compatible.Unix.xml @@ -0,0 +1,139 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + return (byte)((_bitfield2 >> 22) & 0x1u); + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + + + + int + + return (int)(_bitfield2 << 8) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + + + + int + + return (int)(_bitfield2 << 7) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Compatible.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Compatible.Windows.xml new file mode 100644 index 00000000..e18ada54 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Compatible.Windows.xml @@ -0,0 +1,145 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + + byte + + return (byte)(_bitfield3 & 0x1u); + + + + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + + + + int + + + int + + return (_bitfield4 << 31) >> 31; + + + + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + + + + int + + return (_bitfield4 << 30) >> 31; + + + + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..ac72a129 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Default.Unix.xml @@ -0,0 +1,139 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + return (byte)((_bitfield2 >> 22) & 0x1u); + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + + + + int + + return (int)(_bitfield2 << 8) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + + + + int + + return (int)(_bitfield2 << 7) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Default.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Default.Windows.xml new file mode 100644 index 00000000..e18ada54 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Default.Windows.xml @@ -0,0 +1,145 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + + byte + + return (byte)(_bitfield3 & 0x1u); + + + + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + + + + int + + + int + + return (_bitfield4 << 31) >> 31; + + + + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + + + + int + + return (_bitfield4 << 30) >> 31; + + + + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..ac72a129 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Latest.Unix.xml @@ -0,0 +1,139 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + return (byte)((_bitfield2 >> 22) & 0x1u); + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + + + + int + + return (int)(_bitfield2 << 8) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + + + + int + + return (int)(_bitfield2 << 7) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Latest.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Latest.Windows.xml new file mode 100644 index 00000000..e18ada54 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Latest.Windows.xml @@ -0,0 +1,145 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + + byte + + return (byte)(_bitfield3 & 0x1u); + + + + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + + + + int + + + int + + return (_bitfield4 << 31) >> 31; + + + + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + + + + int + + return (_bitfield4 << 30) >> 31; + + + + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..ac72a129 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Preview.Unix.xml @@ -0,0 +1,139 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + return (byte)((_bitfield2 >> 22) & 0x1u); + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); + + + + int + + return (int)(_bitfield2 << 8) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); + + + + int + + return (int)(_bitfield2 << 7) >> 31; + + + + _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Preview.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Preview.Windows.xml new file mode 100644 index 00000000..e18ada54 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/BitfieldTest.Xml.Preview.Windows.xml @@ -0,0 +1,145 @@ + + + + + + uint + + + uint + + return _bitfield1 & 0xFFFFFFu; + + + + _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); + + + + uint + + + uint + + return _bitfield2 & 0xFFFFu; + + + + _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); + + + + uint + + return (_bitfield2 >> 16) & 0x7u; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); + + + + int + + return (int)(_bitfield2 << 10) >> 29; + + + + _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); + + + + byte + + + byte + + return (byte)(_bitfield3 & 0x1u); + + + + _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); + + + + int + + + int + + return (_bitfield4 << 31) >> 31; + + + + _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); + + + + int + + return (_bitfield4 << 30) >> 31; + + + + _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); + + + + + + uint + + + uint + + return _bitfield1 & 0x1u; + + + + _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); + + + + int + + + uint + + + uint + + return _bitfield2 & 0x1u; + + + + _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); + + + + + + uint + + + uint + + return _bitfield & 0x1u; + + + + _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); + + + + uint + + return (_bitfield >> 1) & 0x1u; + + + + _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/ExcludeTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/ExcludeTest.CSharp.cs new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/ExcludeTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/ExcludeTest.Xml.xml new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs new file mode 100644 index 00000000..b998b503 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs @@ -0,0 +1,69 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + public MyUnion e1_0_0_0; + + public MyUnion e0_0_1_0; + public MyUnion e1_0_1_0; + + public MyUnion e0_0_2_0; + public MyUnion e1_0_2_0; + + public MyUnion e0_0_0_1; + public MyUnion e1_0_0_1; + + public MyUnion e0_0_1_1; + public MyUnion e1_0_1_1; + + public MyUnion e0_0_2_1; + public MyUnion e1_0_2_1; + + public MyUnion e0_0_0_2; + public MyUnion e1_0_0_2; + + public MyUnion e0_0_1_2; + public MyUnion e1_0_1_2; + + public MyUnion e0_0_2_2; + public MyUnion e1_0_2_2; + + public MyUnion e0_0_0_3; + public MyUnion e1_0_0_3; + + public MyUnion e0_0_1_3; + public MyUnion e1_0_1_3; + + public MyUnion e0_0_2_3; + public MyUnion e1_0_2_3; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs new file mode 100644 index 00000000..d6fe3234 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs new file mode 100644 index 00000000..d6fe3234 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs new file mode 100644 index 00000000..d6fe3234 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml new file mode 100644 index 00000000..64ce616d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml @@ -0,0 +1,101 @@ + + + + + + double + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml new file mode 100644 index 00000000..8a58cc50 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyUnion + + + InlineArray(2 * 1 * 3 * 4) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml new file mode 100644 index 00000000..8a58cc50 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyUnion + + + InlineArray(2 * 1 * 3 * 4) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml new file mode 100644 index 00000000..8a58cc50 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyUnion + + + InlineArray(2 * 1 * 3 * 4) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs new file mode 100644 index 00000000..93e49230 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs @@ -0,0 +1,69 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + public MyUnion e1_0_0_0; + + public MyUnion e0_0_1_0; + public MyUnion e1_0_1_0; + + public MyUnion e0_0_2_0; + public MyUnion e1_0_2_0; + + public MyUnion e0_0_0_1; + public MyUnion e1_0_0_1; + + public MyUnion e0_0_1_1; + public MyUnion e1_0_1_1; + + public MyUnion e0_0_2_1; + public MyUnion e1_0_2_1; + + public MyUnion e0_0_0_2; + public MyUnion e1_0_0_2; + + public MyUnion e0_0_1_2; + public MyUnion e1_0_1_2; + + public MyUnion e0_0_2_2; + public MyUnion e1_0_2_2; + + public MyUnion e0_0_0_3; + public MyUnion e1_0_0_3; + + public MyUnion e0_0_1_3; + public MyUnion e1_0_1_3; + + public MyUnion e0_0_2_3; + public MyUnion e1_0_2_3; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs new file mode 100644 index 00000000..6f2918be --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs new file mode 100644 index 00000000..6f2918be --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs new file mode 100644 index 00000000..6f2918be --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml new file mode 100644 index 00000000..85cdfa76 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml @@ -0,0 +1,101 @@ + + + + + + float + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml new file mode 100644 index 00000000..e26f8213 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyUnion + + + InlineArray(2 * 1 * 3 * 4) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml new file mode 100644 index 00000000..e26f8213 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyUnion + + + InlineArray(2 * 1 * 3 * 4) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml new file mode 100644 index 00000000..e26f8213 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyUnion + + + InlineArray(2 * 1 * 3 * 4) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs new file mode 100644 index 00000000..62224d3b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs @@ -0,0 +1,69 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + public MyUnion e1_0_0_0; + + public MyUnion e0_0_1_0; + public MyUnion e1_0_1_0; + + public MyUnion e0_0_2_0; + public MyUnion e1_0_2_0; + + public MyUnion e0_0_0_1; + public MyUnion e1_0_0_1; + + public MyUnion e0_0_1_1; + public MyUnion e1_0_1_1; + + public MyUnion e0_0_2_1; + public MyUnion e1_0_2_1; + + public MyUnion e0_0_0_2; + public MyUnion e1_0_0_2; + + public MyUnion e0_0_1_2; + public MyUnion e1_0_1_2; + + public MyUnion e0_0_2_2; + public MyUnion e1_0_2_2; + + public MyUnion e0_0_0_3; + public MyUnion e1_0_0_3; + + public MyUnion e0_0_1_3; + public MyUnion e1_0_1_3; + + public MyUnion e0_0_2_3; + public MyUnion e1_0_2_3; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs new file mode 100644 index 00000000..64795179 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs new file mode 100644 index 00000000..64795179 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs new file mode 100644 index 00000000..64795179 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml new file mode 100644 index 00000000..fa814c0a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml @@ -0,0 +1,101 @@ + + + + + + int + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml new file mode 100644 index 00000000..9bc4facb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyUnion + + + InlineArray(2 * 1 * 3 * 4) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml new file mode 100644 index 00000000..9bc4facb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyUnion + + + InlineArray(2 * 1 * 3 * 4) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml new file mode 100644 index 00000000..9bc4facb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyUnion + + + InlineArray(2 * 1 * 3 * 4) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs new file mode 100644 index 00000000..a62d8c78 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs @@ -0,0 +1,69 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + public MyUnion e1_0_0_0; + + public MyUnion e0_0_1_0; + public MyUnion e1_0_1_0; + + public MyUnion e0_0_2_0; + public MyUnion e1_0_2_0; + + public MyUnion e0_0_0_1; + public MyUnion e1_0_0_1; + + public MyUnion e0_0_1_1; + public MyUnion e1_0_1_1; + + public MyUnion e0_0_2_1; + public MyUnion e1_0_2_1; + + public MyUnion e0_0_0_2; + public MyUnion e1_0_0_2; + + public MyUnion e0_0_1_2; + public MyUnion e1_0_1_2; + + public MyUnion e0_0_2_2; + public MyUnion e1_0_2_2; + + public MyUnion e0_0_0_3; + public MyUnion e1_0_0_3; + + public MyUnion e0_0_1_3; + public MyUnion e1_0_1_3; + + public MyUnion e0_0_2_3; + public MyUnion e1_0_2_3; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs new file mode 100644 index 00000000..7863deff --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs new file mode 100644 index 00000000..7863deff --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs new file mode 100644 index 00000000..7863deff --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml new file mode 100644 index 00000000..5db45631 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml @@ -0,0 +1,101 @@ + + + + + + short + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0_0_0_0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml new file mode 100644 index 00000000..c14c6f4c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyUnion + + + InlineArray(2 * 1 * 3 * 4) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml new file mode 100644 index 00000000..c14c6f4c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyUnion + + + InlineArray(2 * 1 * 3 * 4) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml new file mode 100644 index 00000000..c14c6f4c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyUnion + + + InlineArray(2 * 1 * 3 * 4) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs new file mode 100644 index 00000000..82ab6e3d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs @@ -0,0 +1,37 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Default.cs new file mode 100644 index 00000000..836f3959 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Default.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Latest.cs new file mode 100644 index 00000000..836f3959 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Latest.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Preview.cs new file mode 100644 index 00000000..836f3959 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.CSharp.Preview.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Compatible.xml new file mode 100644 index 00000000..fe48fb05 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + double + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Default.xml new file mode 100644 index 00000000..f8dc942f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Latest.xml new file mode 100644 index 00000000..f8dc942f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Preview.xml new file mode 100644 index 00000000..f8dc942f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_double_5Fdouble.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs new file mode 100644 index 00000000..dd1517fa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs @@ -0,0 +1,37 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Default.cs new file mode 100644 index 00000000..69c7aa91 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Default.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Latest.cs new file mode 100644 index 00000000..69c7aa91 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Latest.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Preview.cs new file mode 100644 index 00000000..69c7aa91 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.CSharp.Preview.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Compatible.xml new file mode 100644 index 00000000..e2a52cd0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + float + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Default.xml new file mode 100644 index 00000000..fb472c0c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Latest.xml new file mode 100644 index 00000000..fb472c0c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Preview.xml new file mode 100644 index 00000000..fb472c0c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_float_5Ffloat.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Compatible.cs new file mode 100644 index 00000000..1a9cbcf8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Compatible.cs @@ -0,0 +1,37 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Default.cs new file mode 100644 index 00000000..a122b44e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Default.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Latest.cs new file mode 100644 index 00000000..a122b44e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Latest.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Preview.cs new file mode 100644 index 00000000..a122b44e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.CSharp.Preview.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Compatible.xml new file mode 100644 index 00000000..8d48f7c0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + int + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Default.xml new file mode 100644 index 00000000..072b466a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Latest.xml new file mode 100644 index 00000000..072b466a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Preview.xml new file mode 100644 index 00000000..072b466a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_int_5Fint.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Compatible.cs new file mode 100644 index 00000000..bbe7f238 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Compatible.cs @@ -0,0 +1,37 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Default.cs new file mode 100644 index 00000000..c69e2dfa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Default.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Latest.cs new file mode 100644 index 00000000..c69e2dfa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Latest.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Preview.cs new file mode 100644 index 00000000..c69e2dfa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.CSharp.Preview.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Compatible.xml new file mode 100644 index 00000000..87d08fea --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + short + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Default.xml new file mode 100644 index 00000000..968fcb68 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Latest.xml new file mode 100644 index 00000000..968fcb68 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Preview.xml new file mode 100644 index 00000000..968fcb68 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTest_short_5Fshort.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs new file mode 100644 index 00000000..c0d74687 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs @@ -0,0 +1,37 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs new file mode 100644 index 00000000..3617f76b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs new file mode 100644 index 00000000..3617f76b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs new file mode 100644 index 00000000..3617f76b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml new file mode 100644 index 00000000..c80ac414 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + double + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml new file mode 100644 index 00000000..8444db87 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml new file mode 100644 index 00000000..8444db87 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml new file mode 100644 index 00000000..8444db87 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + double + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs new file mode 100644 index 00000000..c5c08814 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs @@ -0,0 +1,37 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs new file mode 100644 index 00000000..06c3db75 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs new file mode 100644 index 00000000..06c3db75 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs new file mode 100644 index 00000000..06c3db75 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml new file mode 100644 index 00000000..648ad6dc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + float + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml new file mode 100644 index 00000000..93760200 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml new file mode 100644 index 00000000..93760200 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml new file mode 100644 index 00000000..93760200 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + float + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs new file mode 100644 index 00000000..269a2520 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs @@ -0,0 +1,37 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs new file mode 100644 index 00000000..d265be9a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs new file mode 100644 index 00000000..d265be9a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs new file mode 100644 index 00000000..d265be9a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml new file mode 100644 index 00000000..a3ce127f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + int + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Default.xml new file mode 100644 index 00000000..60489cd1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml new file mode 100644 index 00000000..60489cd1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml new file mode 100644 index 00000000..60489cd1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + int + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs new file mode 100644 index 00000000..6d32f344 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs @@ -0,0 +1,37 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs new file mode 100644 index 00000000..1c269675 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs new file mode 100644 index 00000000..1c269675 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs new file mode 100644 index 00000000..1c269675 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs @@ -0,0 +1,26 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml new file mode 100644 index 00000000..40590d67 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + short + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml new file mode 100644 index 00000000..cea7b477 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml new file mode 100644 index 00000000..cea7b477 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml new file mode 100644 index 00000000..cea7b477 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + short + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..9fb1f78f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Compatible.cs @@ -0,0 +1,38 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Default.cs new file mode 100644 index 00000000..95cd2d43 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Default.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Latest.cs new file mode 100644 index 00000000..95cd2d43 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Latest.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Preview.cs new file mode 100644 index 00000000..95cd2d43 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.CSharp.Preview.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Compatible.xml new file mode 100644 index 00000000..9972cc04 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + byte + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Default.xml new file mode 100644 index 00000000..c4b1b035 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + byte + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Latest.xml new file mode 100644 index 00000000..c4b1b035 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + byte + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Preview.xml new file mode 100644 index 00000000..c4b1b035 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_bool_5Fbyte.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + byte + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Compatible.cs new file mode 100644 index 00000000..1bef67c6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Compatible.cs @@ -0,0 +1,38 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long")] + public long value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Default.cs new file mode 100644 index 00000000..5de3a377 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Default.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long")] + public long value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Latest.cs new file mode 100644 index 00000000..5de3a377 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Latest.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long")] + public long value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Preview.cs new file mode 100644 index 00000000..5de3a377 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.CSharp.Preview.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long")] + public long value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Compatible.xml new file mode 100644 index 00000000..83642041 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + long + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Default.xml new file mode 100644 index 00000000..c73e1bc9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + long + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Latest.xml new file mode 100644 index 00000000..c73e1bc9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + long + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Preview.xml new file mode 100644 index 00000000..c73e1bc9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_long_20long_5Flong.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + long + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..3d0294b4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Compatible.cs @@ -0,0 +1,38 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Default.cs new file mode 100644 index 00000000..9bc3a6d5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Default.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Latest.cs new file mode 100644 index 00000000..9bc3a6d5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Latest.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Preview.cs new file mode 100644 index 00000000..9bc3a6d5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.Preview.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Compatible.xml new file mode 100644 index 00000000..b1a7c5fe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + sbyte + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Default.xml new file mode 100644 index 00000000..11764a36 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + sbyte + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Latest.xml new file mode 100644 index 00000000..11764a36 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + sbyte + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Preview.xml new file mode 100644 index 00000000..11764a36 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + sbyte + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..0cff7d2a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs @@ -0,0 +1,38 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Default.cs new file mode 100644 index 00000000..0607980a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Default.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Latest.cs new file mode 100644 index 00000000..0607980a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Latest.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Preview.cs new file mode 100644 index 00000000..0607980a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.Preview.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Compatible.xml new file mode 100644 index 00000000..ba97b200 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + byte + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Default.xml new file mode 100644 index 00000000..53df6c08 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + byte + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Latest.xml new file mode 100644 index 00000000..53df6c08 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + byte + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Preview.xml new file mode 100644 index 00000000..53df6c08 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + byte + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Compatible.cs new file mode 100644 index 00000000..8911055d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Compatible.cs @@ -0,0 +1,38 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Default.cs new file mode 100644 index 00000000..b0bebdd8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Default.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Latest.cs new file mode 100644 index 00000000..b0bebdd8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Latest.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Preview.cs new file mode 100644 index 00000000..b0bebdd8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.Preview.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Compatible.xml new file mode 100644 index 00000000..44af27e3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + uint + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Default.xml new file mode 100644 index 00000000..43d1e56d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + uint + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Latest.xml new file mode 100644 index 00000000..43d1e56d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + uint + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Preview.xml new file mode 100644 index 00000000..43d1e56d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + uint + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs new file mode 100644 index 00000000..be5270b8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs @@ -0,0 +1,38 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs new file mode 100644 index 00000000..1d000776 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs new file mode 100644 index 00000000..1d000776 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs new file mode 100644 index 00000000..1d000776 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml new file mode 100644 index 00000000..c981d218 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + ulong + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Default.xml new file mode 100644 index 00000000..5667b59d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + ulong + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml new file mode 100644 index 00000000..5667b59d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + ulong + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml new file mode 100644 index 00000000..5667b59d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + ulong + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Compatible.cs new file mode 100644 index 00000000..4ab12701 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Compatible.cs @@ -0,0 +1,38 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + public MyUnion e1; + public MyUnion e2; + + public unsafe ref MyUnion this[int index] + { + get + { + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Default.cs new file mode 100644 index 00000000..aeed3565 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Default.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Latest.cs new file mode 100644 index 00000000..aeed3565 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Latest.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Preview.cs new file mode 100644 index 00000000..aeed3565 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.Preview.cs @@ -0,0 +1,27 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public MyUnion e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Compatible.xml new file mode 100644 index 00000000..e996d13f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Compatible.xml @@ -0,0 +1,38 @@ + + + + + + ushort + + + + + MyUnion + + + + MyUnion + + + MyUnion + + + MyUnion + + + ref MyUnion + + int + + + fixed (MyUnion* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Default.xml new file mode 100644 index 00000000..82dba2e2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Default.xml @@ -0,0 +1,21 @@ + + + + + + ushort + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Latest.xml new file mode 100644 index 00000000..82dba2e2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Latest.xml @@ -0,0 +1,21 @@ + + + + + + ushort + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Preview.xml new file mode 100644 index 00000000..82dba2e2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferNonPrimitiveWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.Preview.xml @@ -0,0 +1,21 @@ + + + + + + ushort + + + + + MyUnion + + + InlineArray(3) + + MyUnion + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.CSharp.cs new file mode 100644 index 00000000..a56d836a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.CSharp.cs @@ -0,0 +1,30 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("double *[3]")] + public _c_e__FixedBuffer c; + + public unsafe partial struct _c_e__FixedBuffer + { + public double* e0; + public double* e1; + public double* e2; + + public ref double* this[int index] + { + get + { + fixed (double** pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.Xml.xml new file mode 100644 index 00000000..df40f1b6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_double_20_2A_5Fdouble_2A.Xml.xml @@ -0,0 +1,33 @@ + + + + + + double* + + + + double* + + + double* + + + double* + + + ref double* + + int + + + fixed (double** pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.CSharp.cs new file mode 100644 index 00000000..324f52e7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.CSharp.cs @@ -0,0 +1,30 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("float *[3]")] + public _c_e__FixedBuffer c; + + public unsafe partial struct _c_e__FixedBuffer + { + public float* e0; + public float* e1; + public float* e2; + + public ref float* this[int index] + { + get + { + fixed (float** pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.Xml.xml new file mode 100644 index 00000000..53e7e7ae --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_float_20_2A_5Ffloat_2A.Xml.xml @@ -0,0 +1,33 @@ + + + + + + float* + + + + float* + + + float* + + + float* + + + ref float* + + int + + + fixed (float** pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.CSharp.cs new file mode 100644 index 00000000..37269f66 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.CSharp.cs @@ -0,0 +1,30 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("int *[3]")] + public _c_e__FixedBuffer c; + + public unsafe partial struct _c_e__FixedBuffer + { + public int* e0; + public int* e1; + public int* e2; + + public ref int* this[int index] + { + get + { + fixed (int** pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.Xml.xml new file mode 100644 index 00000000..762a02e4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_int_20_2A_5Fint_2A.Xml.xml @@ -0,0 +1,33 @@ + + + + + + int* + + + + int* + + + int* + + + int* + + + ref int* + + int + + + fixed (int** pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.CSharp.cs new file mode 100644 index 00000000..53291adb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.CSharp.cs @@ -0,0 +1,30 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("short *[3]")] + public _c_e__FixedBuffer c; + + public unsafe partial struct _c_e__FixedBuffer + { + public short* e0; + public short* e1; + public short* e2; + + public ref short* this[int index] + { + get + { + fixed (short** pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.Xml.xml new file mode 100644 index 00000000..464d75e1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPointerTest_short_20_2A_5Fshort_2A.Xml.xml @@ -0,0 +1,33 @@ + + + + + + short* + + + + short* + + + short* + + + short* + + + ref short* + + int + + + fixed (short** pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs new file mode 100644 index 00000000..0d7d49b1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("double[2][1][3][4]")] + public fixed double c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs new file mode 100644 index 00000000..807bab88 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("double[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public double e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs new file mode 100644 index 00000000..807bab88 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("double[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public double e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs new file mode 100644 index 00000000..807bab88 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("double[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public double e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml new file mode 100644 index 00000000..a0e0c938 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml new file mode 100644 index 00000000..b205f761 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(2 * 1 * 3 * 4) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml new file mode 100644 index 00000000..b205f761 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(2 * 1 * 3 * 4) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml new file mode 100644 index 00000000..b205f761 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_double_5Fdouble.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(2 * 1 * 3 * 4) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs new file mode 100644 index 00000000..8708bafd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("float[2][1][3][4]")] + public fixed float c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs new file mode 100644 index 00000000..de835b08 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("float[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public float e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs new file mode 100644 index 00000000..de835b08 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("float[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public float e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs new file mode 100644 index 00000000..de835b08 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("float[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public float e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml new file mode 100644 index 00000000..dc11d43e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml new file mode 100644 index 00000000..0e1809f7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(2 * 1 * 3 * 4) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml new file mode 100644 index 00000000..0e1809f7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(2 * 1 * 3 * 4) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml new file mode 100644 index 00000000..0e1809f7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_float_5Ffloat.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(2 * 1 * 3 * 4) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs new file mode 100644 index 00000000..c9e34b8c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("int[2][1][3][4]")] + public fixed int c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs new file mode 100644 index 00000000..038d5e97 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("int[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public int e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs new file mode 100644 index 00000000..038d5e97 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("int[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public int e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs new file mode 100644 index 00000000..038d5e97 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("int[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public int e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml new file mode 100644 index 00000000..e1feb58d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml new file mode 100644 index 00000000..ae3fc7b2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(2 * 1 * 3 * 4) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml new file mode 100644 index 00000000..ae3fc7b2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(2 * 1 * 3 * 4) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml new file mode 100644 index 00000000..ae3fc7b2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_int_5Fint.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(2 * 1 * 3 * 4) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Compatible.cs new file mode 100644 index 00000000..4739b508 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long[2][1][3][4]")] + public fixed long c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Default.cs new file mode 100644 index 00000000..7814d878 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public long e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Latest.cs new file mode 100644 index 00000000..7814d878 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public long e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Preview.cs new file mode 100644 index 00000000..7814d878 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public long e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Compatible.xml new file mode 100644 index 00000000..456177d6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + long + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Default.xml new file mode 100644 index 00000000..59318b30 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(2 * 1 * 3 * 4) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Latest.xml new file mode 100644 index 00000000..59318b30 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(2 * 1 * 3 * 4) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Preview.xml new file mode 100644 index 00000000..59318b30 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_long_20long_5Flong.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(2 * 1 * 3 * 4) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs new file mode 100644 index 00000000..32ec48d7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("short[2][1][3][4]")] + public fixed short c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs new file mode 100644 index 00000000..c2f7333c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("short[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public short e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs new file mode 100644 index 00000000..c2f7333c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("short[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public short e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs new file mode 100644 index 00000000..c2f7333c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("short[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public short e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml new file mode 100644 index 00000000..beb5ebef --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml new file mode 100644 index 00000000..7705d623 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(2 * 1 * 3 * 4) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml new file mode 100644 index 00000000..7705d623 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(2 * 1 * 3 * 4) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml new file mode 100644 index 00000000..7705d623 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_short_5Fshort.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(2 * 1 * 3 * 4) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..5c43cb51 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char[2][1][3][4]")] + public fixed sbyte c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Default.cs new file mode 100644 index 00000000..855f2e71 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Latest.cs new file mode 100644 index 00000000..855f2e71 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Preview.cs new file mode 100644 index 00000000..855f2e71 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Compatible.xml new file mode 100644 index 00000000..dabb315f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + sbyte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Default.xml new file mode 100644 index 00000000..9e2e2458 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(2 * 1 * 3 * 4) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Latest.xml new file mode 100644 index 00000000..9e2e2458 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(2 * 1 * 3 * 4) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Preview.xml new file mode 100644 index 00000000..9e2e2458 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_signed_20char_5Fsbyte.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(2 * 1 * 3 * 4) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..f90641d3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char[2][1][3][4]")] + public fixed byte c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Default.cs new file mode 100644 index 00000000..229e35e0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public byte e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Latest.cs new file mode 100644 index 00000000..229e35e0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public byte e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Preview.cs new file mode 100644 index 00000000..229e35e0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public byte e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Compatible.xml new file mode 100644 index 00000000..163e5db4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Default.xml new file mode 100644 index 00000000..4755355b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(2 * 1 * 3 * 4) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Latest.xml new file mode 100644 index 00000000..4755355b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(2 * 1 * 3 * 4) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Preview.xml new file mode 100644 index 00000000..4755355b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20char_5Fbyte.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(2 * 1 * 3 * 4) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Compatible.cs new file mode 100644 index 00000000..5fb5ec10 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int[2][1][3][4]")] + public fixed uint c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Default.cs new file mode 100644 index 00000000..b25a25bd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public uint e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Latest.cs new file mode 100644 index 00000000..b25a25bd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public uint e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Preview.cs new file mode 100644 index 00000000..b25a25bd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public uint e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Compatible.xml new file mode 100644 index 00000000..c7e1a215 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Default.xml new file mode 100644 index 00000000..b9acf37d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(2 * 1 * 3 * 4) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Latest.xml new file mode 100644 index 00000000..b9acf37d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(2 * 1 * 3 * 4) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Preview.xml new file mode 100644 index 00000000..b9acf37d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20int_5Fuint.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(2 * 1 * 3 * 4) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs new file mode 100644 index 00000000..37fa0e4f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long[2][1][3][4]")] + public fixed ulong c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs new file mode 100644 index 00000000..e0b6e3ef --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public ulong e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs new file mode 100644 index 00000000..e0b6e3ef --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public ulong e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs new file mode 100644 index 00000000..e0b6e3ef --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public ulong e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml new file mode 100644 index 00000000..35611605 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + ulong + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Default.xml new file mode 100644 index 00000000..6a5918b6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(2 * 1 * 3 * 4) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml new file mode 100644 index 00000000..6a5918b6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(2 * 1 * 3 * 4) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml new file mode 100644 index 00000000..6a5918b6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(2 * 1 * 3 * 4) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Compatible.cs new file mode 100644 index 00000000..29789dd7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short[2][1][3][4]")] + public fixed ushort c[2 * 1 * 3 * 4]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Default.cs new file mode 100644 index 00000000..38394780 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public ushort e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Latest.cs new file mode 100644 index 00000000..38394780 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public ushort e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Preview.cs new file mode 100644 index 00000000..38394780 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short[2][1][3][4]")] + public _c_e__FixedBuffer c; + + [InlineArray(2 * 1 * 3 * 4)] + public partial struct _c_e__FixedBuffer + { + public ushort e0_0_0_0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Compatible.xml new file mode 100644 index 00000000..ff497a51 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + ushort + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Default.xml new file mode 100644 index 00000000..107453fe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(2 * 1 * 3 * 4) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Latest.xml new file mode 100644 index 00000000..107453fe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(2 * 1 * 3 * 4) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Preview.xml new file mode 100644 index 00000000..107453fe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveMultidimensionalTest_unsigned_20short_5Fushort.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(2 * 1 * 3 * 4) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs new file mode 100644 index 00000000..5926dfd5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("double[3]")] + public fixed double c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Default.cs new file mode 100644 index 00000000..455d320c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("double[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public double e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Latest.cs new file mode 100644 index 00000000..455d320c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("double[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public double e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Preview.cs new file mode 100644 index 00000000..455d320c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("double[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public double e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Compatible.xml new file mode 100644 index 00000000..88816062 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Default.xml new file mode 100644 index 00000000..d2e3f6c5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(3) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Latest.xml new file mode 100644 index 00000000..d2e3f6c5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(3) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Preview.xml new file mode 100644 index 00000000..d2e3f6c5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_double_5Fdouble.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(3) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs new file mode 100644 index 00000000..8688dd77 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("float[3]")] + public fixed float c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Default.cs new file mode 100644 index 00000000..2d8c5fef --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("float[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public float e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Latest.cs new file mode 100644 index 00000000..2d8c5fef --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("float[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public float e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Preview.cs new file mode 100644 index 00000000..2d8c5fef --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("float[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public float e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Compatible.xml new file mode 100644 index 00000000..627f9026 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Default.xml new file mode 100644 index 00000000..2bcf6110 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(3) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Latest.xml new file mode 100644 index 00000000..2bcf6110 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(3) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Preview.xml new file mode 100644 index 00000000..2bcf6110 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_float_5Ffloat.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(3) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Compatible.cs new file mode 100644 index 00000000..b0b7f392 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("int[3]")] + public fixed int c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Default.cs new file mode 100644 index 00000000..b5fc1ea5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("int[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Latest.cs new file mode 100644 index 00000000..b5fc1ea5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("int[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Preview.cs new file mode 100644 index 00000000..b5fc1ea5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("int[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Compatible.xml new file mode 100644 index 00000000..9f2f1f43 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Default.xml new file mode 100644 index 00000000..1cfd620d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(3) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Latest.xml new file mode 100644 index 00000000..1cfd620d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(3) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Preview.xml new file mode 100644 index 00000000..1cfd620d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_int_5Fint.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(3) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Compatible.cs new file mode 100644 index 00000000..6a9096be --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long[3]")] + public fixed long c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Default.cs new file mode 100644 index 00000000..dc877a05 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public long e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Latest.cs new file mode 100644 index 00000000..dc877a05 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public long e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Preview.cs new file mode 100644 index 00000000..dc877a05 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public long e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Compatible.xml new file mode 100644 index 00000000..ffe2676f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + long + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Default.xml new file mode 100644 index 00000000..7155cb78 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(3) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Latest.xml new file mode 100644 index 00000000..7155cb78 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(3) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Preview.xml new file mode 100644 index 00000000..7155cb78 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_long_20long_5Flong.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(3) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Compatible.cs new file mode 100644 index 00000000..fb03ac26 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("short[3]")] + public fixed short c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Default.cs new file mode 100644 index 00000000..962501a9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("short[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public short e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Latest.cs new file mode 100644 index 00000000..962501a9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("short[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public short e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Preview.cs new file mode 100644 index 00000000..962501a9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("short[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public short e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Compatible.xml new file mode 100644 index 00000000..4e761f75 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Default.xml new file mode 100644 index 00000000..b47cf01b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(3) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Latest.xml new file mode 100644 index 00000000..b47cf01b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(3) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Preview.xml new file mode 100644 index 00000000..b47cf01b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_short_5Fshort.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(3) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..44e18b2c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char[3]")] + public fixed sbyte c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Default.cs new file mode 100644 index 00000000..d25926a4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Latest.cs new file mode 100644 index 00000000..d25926a4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Preview.cs new file mode 100644 index 00000000..d25926a4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Compatible.xml new file mode 100644 index 00000000..fbd923f9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + sbyte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Default.xml new file mode 100644 index 00000000..8a9b54ad --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(3) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Latest.xml new file mode 100644 index 00000000..8a9b54ad --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(3) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Preview.xml new file mode 100644 index 00000000..8a9b54ad --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_signed_20char_5Fsbyte.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(3) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..0707a8d0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char[3]")] + public fixed byte c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Default.cs new file mode 100644 index 00000000..6a189d7d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public byte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Latest.cs new file mode 100644 index 00000000..6a189d7d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public byte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Preview.cs new file mode 100644 index 00000000..6a189d7d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public byte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Compatible.xml new file mode 100644 index 00000000..f8800a3f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Default.xml new file mode 100644 index 00000000..7e5e7769 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(3) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Latest.xml new file mode 100644 index 00000000..7e5e7769 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(3) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Preview.xml new file mode 100644 index 00000000..7e5e7769 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20char_5Fbyte.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(3) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Compatible.cs new file mode 100644 index 00000000..20f4e29f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int[3]")] + public fixed uint c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Default.cs new file mode 100644 index 00000000..7976bc29 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public uint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Latest.cs new file mode 100644 index 00000000..7976bc29 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public uint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Preview.cs new file mode 100644 index 00000000..7976bc29 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public uint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Compatible.xml new file mode 100644 index 00000000..20f4e22b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Default.xml new file mode 100644 index 00000000..b36aa683 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(3) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Latest.xml new file mode 100644 index 00000000..b36aa683 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(3) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Preview.xml new file mode 100644 index 00000000..b36aa683 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20int_5Fuint.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(3) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs new file mode 100644 index 00000000..bdf3bf5b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long[3]")] + public fixed ulong c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs new file mode 100644 index 00000000..1fbfc59f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ulong e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs new file mode 100644 index 00000000..1fbfc59f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ulong e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs new file mode 100644 index 00000000..1fbfc59f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ulong e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml new file mode 100644 index 00000000..90e4a7fd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + ulong + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Default.xml new file mode 100644 index 00000000..a17189a1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(3) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml new file mode 100644 index 00000000..a17189a1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(3) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml new file mode 100644 index 00000000..a17189a1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(3) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Compatible.cs new file mode 100644 index 00000000..7fdbbdbe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short[3]")] + public fixed ushort c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Default.cs new file mode 100644 index 00000000..a3721721 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ushort e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Latest.cs new file mode 100644 index 00000000..a3721721 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ushort e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Preview.cs new file mode 100644 index 00000000..a3721721 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short[3]")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ushort e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Compatible.xml new file mode 100644 index 00000000..1876e71a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + ushort + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Default.xml new file mode 100644 index 00000000..c0594172 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(3) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Latest.xml new file mode 100644 index 00000000..c0594172 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(3) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Preview.xml new file mode 100644 index 00000000..c0594172 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTest_unsigned_20short_5Fushort.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(3) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs new file mode 100644 index 00000000..3ab1db6e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public fixed double c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs new file mode 100644 index 00000000..feee9af0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public double e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs new file mode 100644 index 00000000..feee9af0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public double e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs new file mode 100644 index 00000000..feee9af0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public double e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml new file mode 100644 index 00000000..e515cc0c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml new file mode 100644 index 00000000..338b7b2f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(3) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml new file mode 100644 index 00000000..338b7b2f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(3) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml new file mode 100644 index 00000000..338b7b2f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_double_5Fdouble.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + double + + + InlineArray(3) + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs new file mode 100644 index 00000000..d5b831ec --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public fixed float c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs new file mode 100644 index 00000000..4f619c97 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public float e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs new file mode 100644 index 00000000..4f619c97 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public float e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs new file mode 100644 index 00000000..4f619c97 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public float e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml new file mode 100644 index 00000000..0fd4a679 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml new file mode 100644 index 00000000..7ebdf2ca --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(3) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml new file mode 100644 index 00000000..7ebdf2ca --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(3) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml new file mode 100644 index 00000000..7ebdf2ca --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_float_5Ffloat.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + float + + + InlineArray(3) + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs new file mode 100644 index 00000000..17b8257f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public fixed int c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs new file mode 100644 index 00000000..02e4c8fb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs new file mode 100644 index 00000000..02e4c8fb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs new file mode 100644 index 00000000..02e4c8fb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml new file mode 100644 index 00000000..7ee6ea5e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Default.xml new file mode 100644 index 00000000..61f48ff0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(3) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml new file mode 100644 index 00000000..61f48ff0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(3) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml new file mode 100644 index 00000000..61f48ff0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_int_5Fint.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + int + + + InlineArray(3) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Compatible.cs new file mode 100644 index 00000000..3fb3139d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public fixed long c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Default.cs new file mode 100644 index 00000000..9f9ad14b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public long e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Latest.cs new file mode 100644 index 00000000..9f9ad14b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public long e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Preview.cs new file mode 100644 index 00000000..9f9ad14b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public long e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Compatible.xml new file mode 100644 index 00000000..0ea92202 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + long + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Default.xml new file mode 100644 index 00000000..6e49cbc9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(3) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Latest.xml new file mode 100644 index 00000000..6e49cbc9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(3) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Preview.xml new file mode 100644 index 00000000..6e49cbc9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_long_20long_5Flong.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + long + + + InlineArray(3) + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs new file mode 100644 index 00000000..5f0e2376 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public fixed short c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs new file mode 100644 index 00000000..831a86b6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public short e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs new file mode 100644 index 00000000..831a86b6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public short e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs new file mode 100644 index 00000000..831a86b6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public short e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml new file mode 100644 index 00000000..ae71f5b3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml new file mode 100644 index 00000000..1b8472a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(3) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml new file mode 100644 index 00000000..1b8472a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(3) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml new file mode 100644 index 00000000..1b8472a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_short_5Fshort.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + short + + + InlineArray(3) + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..50e84587 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public fixed sbyte c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Default.cs new file mode 100644 index 00000000..e934e334 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Latest.cs new file mode 100644 index 00000000..e934e334 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Preview.cs new file mode 100644 index 00000000..e934e334 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public sbyte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Compatible.xml new file mode 100644 index 00000000..3c3399c4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + sbyte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Default.xml new file mode 100644 index 00000000..eb5db7ac --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(3) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Latest.xml new file mode 100644 index 00000000..eb5db7ac --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(3) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Preview.xml new file mode 100644 index 00000000..eb5db7ac --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_signed_20char_5Fsbyte.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + InlineArray(3) + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs new file mode 100644 index 00000000..4c5575df --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public fixed byte c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Default.cs new file mode 100644 index 00000000..a4df4606 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public byte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Latest.cs new file mode 100644 index 00000000..a4df4606 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public byte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Preview.cs new file mode 100644 index 00000000..a4df4606 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public byte e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Compatible.xml new file mode 100644 index 00000000..023a2c93 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Default.xml new file mode 100644 index 00000000..9ee51743 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(3) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Latest.xml new file mode 100644 index 00000000..9ee51743 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(3) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Preview.xml new file mode 100644 index 00000000..9ee51743 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20char_5Fbyte.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + InlineArray(3) + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Compatible.cs new file mode 100644 index 00000000..ca73b84b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public fixed uint c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Default.cs new file mode 100644 index 00000000..db336d1f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public uint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Latest.cs new file mode 100644 index 00000000..db336d1f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public uint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Preview.cs new file mode 100644 index 00000000..db336d1f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public uint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Compatible.xml new file mode 100644 index 00000000..db613152 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Default.xml new file mode 100644 index 00000000..d6c18f54 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(3) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Latest.xml new file mode 100644 index 00000000..d6c18f54 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(3) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Preview.xml new file mode 100644 index 00000000..d6c18f54 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20int_5Fuint.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + InlineArray(3) + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs new file mode 100644 index 00000000..5d928f95 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public fixed ulong c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs new file mode 100644 index 00000000..344c5a3c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ulong e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs new file mode 100644 index 00000000..344c5a3c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ulong e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs new file mode 100644 index 00000000..344c5a3c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ulong e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml new file mode 100644 index 00000000..1883631a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + ulong + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Default.xml new file mode 100644 index 00000000..cbd1693b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(3) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml new file mode 100644 index 00000000..cbd1693b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(3) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml new file mode 100644 index 00000000..cbd1693b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20long_20long_5Fulong.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + InlineArray(3) + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Compatible.cs new file mode 100644 index 00000000..8e8aebdf --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Compatible.cs @@ -0,0 +1,12 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public fixed ushort c[3]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Default.cs new file mode 100644 index 00000000..5aeb3216 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Default.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ushort e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Latest.cs new file mode 100644 index 00000000..5aeb3216 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Latest.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ushort e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Preview.cs new file mode 100644 index 00000000..5aeb3216 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.CSharp.Preview.cs @@ -0,0 +1,19 @@ +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyBuffer")] + public _c_e__FixedBuffer c; + + [InlineArray(3)] + public partial struct _c_e__FixedBuffer + { + public ushort e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Compatible.xml new file mode 100644 index 00000000..00b30e2c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Compatible.xml @@ -0,0 +1,10 @@ + + + + + + ushort + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Default.xml new file mode 100644 index 00000000..a828d668 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Default.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(3) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Latest.xml new file mode 100644 index 00000000..a828d668 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Latest.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(3) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Preview.xml new file mode 100644 index 00000000..a828d668 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/FixedSizedBufferPrimitiveTypedefTest_unsigned_20short_5Fushort.Xml.Preview.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + InlineArray(3) + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/GuidTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/GuidTest.CSharp.cs new file mode 100644 index 00000000..be649a74 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/GuidTest.CSharp.cs @@ -0,0 +1,28 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + [Guid("00000000-0000-0000-C000-000000000046")] + public partial struct MyUnion1 + { + [FieldOffset(0)] + public int x; + } + + [StructLayout(LayoutKind.Explicit)] + [Guid("00000000-0000-0000-C000-000000000047")] + public partial struct MyUnion2 + { + [FieldOffset(0)] + public int x; + } + + public static partial class Methods + { + public static readonly Guid IID_MyUnion1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); + + public static readonly Guid IID_MyUnion2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/GuidTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/GuidTest.Xml.xml new file mode 100644 index 00000000..72c17583 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/GuidTest.Xml.xml @@ -0,0 +1,19 @@ + + + + + + int + + + + + int + + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Compatible.cs new file mode 100644 index 00000000..5ebb0ab8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Compatible.cs @@ -0,0 +1,73 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + public double r; + + [FieldOffset(0)] + public double g; + + [FieldOffset(0)] + public double b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + public ref double a + { + get + { + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->a; + } + } + } + + public ref MyStruct s + { + get + { + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->s; + } + } + } + + public ref double buffer + { + get + { + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->buffer[0]; + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public double a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("double[4]")] + public fixed double buffer[4]; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Default.cs new file mode 100644 index 00000000..5077a3a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Default.cs @@ -0,0 +1,76 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double r; + + [FieldOffset(0)] + public double g; + + [FieldOffset(0)] + public double b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref double a + { + get + { + return ref Anonymous.a; + } + } + + [UnscopedRef] + public ref MyStruct s + { + get + { + return ref Anonymous.s; + } + } + + [UnscopedRef] + public Span buffer + { + get + { + return Anonymous.buffer; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public double a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("double[4]")] + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + { + public double e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Latest.cs new file mode 100644 index 00000000..5077a3a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Latest.cs @@ -0,0 +1,76 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double r; + + [FieldOffset(0)] + public double g; + + [FieldOffset(0)] + public double b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref double a + { + get + { + return ref Anonymous.a; + } + } + + [UnscopedRef] + public ref MyStruct s + { + get + { + return ref Anonymous.s; + } + } + + [UnscopedRef] + public Span buffer + { + get + { + return Anonymous.buffer; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public double a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("double[4]")] + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + { + public double e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Preview.cs new file mode 100644 index 00000000..5077a3a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.CSharp.Preview.cs @@ -0,0 +1,76 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public double value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double r; + + [FieldOffset(0)] + public double g; + + [FieldOffset(0)] + public double b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref double a + { + get + { + return ref Anonymous.a; + } + } + + [UnscopedRef] + public ref MyStruct s + { + get + { + return ref Anonymous.s; + } + } + + [UnscopedRef] + public Span buffer + { + get + { + return Anonymous.buffer; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public double a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("double[4]")] + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + { + public double e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Compatible.xml new file mode 100644 index 00000000..1e672581 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Compatible.xml @@ -0,0 +1,62 @@ + + + + + + double + + + + + double + + + double + + + double + + + _Anonymous_e__Union + + + ref double + + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->a; + } + + + + ref MyStruct + + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->s; + } + + + + ref double + + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->buffer[0]; + } + + + + + double + + + MyStruct + + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Default.xml new file mode 100644 index 00000000..8c0b09dd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Default.xml @@ -0,0 +1,59 @@ + + + + + + double + + + + + double + + + double + + + double + + + _Anonymous_e__Union + + + ref double + + return ref Anonymous.a; + + + + ref MyStruct + + return ref Anonymous.s; + + + + Span<double> + + return Anonymous.buffer; + + + + + double + + + MyStruct + + + double + + + InlineArray(4) + + double + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Latest.xml new file mode 100644 index 00000000..8c0b09dd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Latest.xml @@ -0,0 +1,59 @@ + + + + + + double + + + + + double + + + double + + + double + + + _Anonymous_e__Union + + + ref double + + return ref Anonymous.a; + + + + ref MyStruct + + return ref Anonymous.s; + + + + Span<double> + + return Anonymous.buffer; + + + + + double + + + MyStruct + + + double + + + InlineArray(4) + + double + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Preview.xml new file mode 100644 index 00000000..8c0b09dd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_double_5Fdouble_5F11_5F5.Xml.Preview.xml @@ -0,0 +1,59 @@ + + + + + + double + + + + + double + + + double + + + double + + + _Anonymous_e__Union + + + ref double + + return ref Anonymous.a; + + + + ref MyStruct + + return ref Anonymous.s; + + + + Span<double> + + return Anonymous.buffer; + + + + + double + + + MyStruct + + + double + + + InlineArray(4) + + double + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Compatible.cs new file mode 100644 index 00000000..04ee0cfe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Compatible.cs @@ -0,0 +1,73 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + public float r; + + [FieldOffset(0)] + public float g; + + [FieldOffset(0)] + public float b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + public ref float a + { + get + { + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->a; + } + } + } + + public ref MyStruct s + { + get + { + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->s; + } + } + } + + public ref float buffer + { + get + { + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->buffer[0]; + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public float a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("float[4]")] + public fixed float buffer[4]; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Default.cs new file mode 100644 index 00000000..4d586be0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Default.cs @@ -0,0 +1,76 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float r; + + [FieldOffset(0)] + public float g; + + [FieldOffset(0)] + public float b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref float a + { + get + { + return ref Anonymous.a; + } + } + + [UnscopedRef] + public ref MyStruct s + { + get + { + return ref Anonymous.s; + } + } + + [UnscopedRef] + public Span buffer + { + get + { + return Anonymous.buffer; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public float a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("float[4]")] + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + { + public float e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Latest.cs new file mode 100644 index 00000000..4d586be0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Latest.cs @@ -0,0 +1,76 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float r; + + [FieldOffset(0)] + public float g; + + [FieldOffset(0)] + public float b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref float a + { + get + { + return ref Anonymous.a; + } + } + + [UnscopedRef] + public ref MyStruct s + { + get + { + return ref Anonymous.s; + } + } + + [UnscopedRef] + public Span buffer + { + get + { + return Anonymous.buffer; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public float a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("float[4]")] + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + { + public float e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Preview.cs new file mode 100644 index 00000000..4d586be0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.CSharp.Preview.cs @@ -0,0 +1,76 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public float value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float r; + + [FieldOffset(0)] + public float g; + + [FieldOffset(0)] + public float b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref float a + { + get + { + return ref Anonymous.a; + } + } + + [UnscopedRef] + public ref MyStruct s + { + get + { + return ref Anonymous.s; + } + } + + [UnscopedRef] + public Span buffer + { + get + { + return Anonymous.buffer; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public float a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("float[4]")] + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + { + public float e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Compatible.xml new file mode 100644 index 00000000..9e5635a9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Compatible.xml @@ -0,0 +1,62 @@ + + + + + + float + + + + + float + + + float + + + float + + + _Anonymous_e__Union + + + ref float + + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->a; + } + + + + ref MyStruct + + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->s; + } + + + + ref float + + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->buffer[0]; + } + + + + + float + + + MyStruct + + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Default.xml new file mode 100644 index 00000000..2c20e790 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Default.xml @@ -0,0 +1,59 @@ + + + + + + float + + + + + float + + + float + + + float + + + _Anonymous_e__Union + + + ref float + + return ref Anonymous.a; + + + + ref MyStruct + + return ref Anonymous.s; + + + + Span<float> + + return Anonymous.buffer; + + + + + float + + + MyStruct + + + float + + + InlineArray(4) + + float + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Latest.xml new file mode 100644 index 00000000..2c20e790 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Latest.xml @@ -0,0 +1,59 @@ + + + + + + float + + + + + float + + + float + + + float + + + _Anonymous_e__Union + + + ref float + + return ref Anonymous.a; + + + + ref MyStruct + + return ref Anonymous.s; + + + + Span<float> + + return Anonymous.buffer; + + + + + float + + + MyStruct + + + float + + + InlineArray(4) + + float + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Preview.xml new file mode 100644 index 00000000..2c20e790 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_float_5Ffloat_5F11_5F5.Xml.Preview.xml @@ -0,0 +1,59 @@ + + + + + + float + + + + + float + + + float + + + float + + + _Anonymous_e__Union + + + ref float + + return ref Anonymous.a; + + + + ref MyStruct + + return ref Anonymous.s; + + + + Span<float> + + return Anonymous.buffer; + + + + + float + + + MyStruct + + + float + + + InlineArray(4) + + float + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Compatible.cs new file mode 100644 index 00000000..bd9a11ad --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Compatible.cs @@ -0,0 +1,73 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + public int r; + + [FieldOffset(0)] + public int g; + + [FieldOffset(0)] + public int b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + public ref int a + { + get + { + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->a; + } + } + } + + public ref MyStruct s + { + get + { + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->s; + } + } + } + + public ref int buffer + { + get + { + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->buffer[0]; + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public int a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("int[4]")] + public fixed int buffer[4]; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Default.cs new file mode 100644 index 00000000..982dd3f5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Default.cs @@ -0,0 +1,76 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int r; + + [FieldOffset(0)] + public int g; + + [FieldOffset(0)] + public int b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref int a + { + get + { + return ref Anonymous.a; + } + } + + [UnscopedRef] + public ref MyStruct s + { + get + { + return ref Anonymous.s; + } + } + + [UnscopedRef] + public Span buffer + { + get + { + return Anonymous.buffer; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public int a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("int[4]")] + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + { + public int e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Latest.cs new file mode 100644 index 00000000..982dd3f5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Latest.cs @@ -0,0 +1,76 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int r; + + [FieldOffset(0)] + public int g; + + [FieldOffset(0)] + public int b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref int a + { + get + { + return ref Anonymous.a; + } + } + + [UnscopedRef] + public ref MyStruct s + { + get + { + return ref Anonymous.s; + } + } + + [UnscopedRef] + public Span buffer + { + get + { + return Anonymous.buffer; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public int a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("int[4]")] + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + { + public int e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Preview.cs new file mode 100644 index 00000000..982dd3f5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.CSharp.Preview.cs @@ -0,0 +1,76 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int r; + + [FieldOffset(0)] + public int g; + + [FieldOffset(0)] + public int b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref int a + { + get + { + return ref Anonymous.a; + } + } + + [UnscopedRef] + public ref MyStruct s + { + get + { + return ref Anonymous.s; + } + } + + [UnscopedRef] + public Span buffer + { + get + { + return Anonymous.buffer; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public int a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("int[4]")] + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + { + public int e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Compatible.xml new file mode 100644 index 00000000..f68e2efb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Compatible.xml @@ -0,0 +1,62 @@ + + + + + + int + + + + + int + + + int + + + int + + + _Anonymous_e__Union + + + ref int + + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->a; + } + + + + ref MyStruct + + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->s; + } + + + + ref int + + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->buffer[0]; + } + + + + + int + + + MyStruct + + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Default.xml new file mode 100644 index 00000000..65232efa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Default.xml @@ -0,0 +1,59 @@ + + + + + + int + + + + + int + + + int + + + int + + + _Anonymous_e__Union + + + ref int + + return ref Anonymous.a; + + + + ref MyStruct + + return ref Anonymous.s; + + + + Span<int> + + return Anonymous.buffer; + + + + + int + + + MyStruct + + + int + + + InlineArray(4) + + int + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Latest.xml new file mode 100644 index 00000000..65232efa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Latest.xml @@ -0,0 +1,59 @@ + + + + + + int + + + + + int + + + int + + + int + + + _Anonymous_e__Union + + + ref int + + return ref Anonymous.a; + + + + ref MyStruct + + return ref Anonymous.s; + + + + Span<int> + + return Anonymous.buffer; + + + + + int + + + MyStruct + + + int + + + InlineArray(4) + + int + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Preview.xml new file mode 100644 index 00000000..65232efa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_int_5Fint_5F11_5F5.Xml.Preview.xml @@ -0,0 +1,59 @@ + + + + + + int + + + + + int + + + int + + + int + + + _Anonymous_e__Union + + + ref int + + return ref Anonymous.a; + + + + ref MyStruct + + return ref Anonymous.s; + + + + Span<int> + + return Anonymous.buffer; + + + + + int + + + MyStruct + + + int + + + InlineArray(4) + + int + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Compatible.cs new file mode 100644 index 00000000..19a71d25 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Compatible.cs @@ -0,0 +1,73 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + public short r; + + [FieldOffset(0)] + public short g; + + [FieldOffset(0)] + public short b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + public ref short a + { + get + { + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->a; + } + } + } + + public ref MyStruct s + { + get + { + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->s; + } + } + } + + public ref short buffer + { + get + { + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->buffer[0]; + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public short a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("short[4]")] + public fixed short buffer[4]; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Default.cs new file mode 100644 index 00000000..a13ee363 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Default.cs @@ -0,0 +1,76 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short r; + + [FieldOffset(0)] + public short g; + + [FieldOffset(0)] + public short b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref short a + { + get + { + return ref Anonymous.a; + } + } + + [UnscopedRef] + public ref MyStruct s + { + get + { + return ref Anonymous.s; + } + } + + [UnscopedRef] + public Span buffer + { + get + { + return Anonymous.buffer; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public short a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("short[4]")] + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + { + public short e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Latest.cs new file mode 100644 index 00000000..a13ee363 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Latest.cs @@ -0,0 +1,76 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short r; + + [FieldOffset(0)] + public short g; + + [FieldOffset(0)] + public short b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref short a + { + get + { + return ref Anonymous.a; + } + } + + [UnscopedRef] + public ref MyStruct s + { + get + { + return ref Anonymous.s; + } + } + + [UnscopedRef] + public Span buffer + { + get + { + return Anonymous.buffer; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public short a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("short[4]")] + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + { + public short e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Preview.cs new file mode 100644 index 00000000..a13ee363 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.CSharp.Preview.cs @@ -0,0 +1,76 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public short value; + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short r; + + [FieldOffset(0)] + public short g; + + [FieldOffset(0)] + public short b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L11_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref short a + { + get + { + return ref Anonymous.a; + } + } + + [UnscopedRef] + public ref MyStruct s + { + get + { + return ref Anonymous.s; + } + } + + [UnscopedRef] + public Span buffer + { + get + { + return Anonymous.buffer; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public short a; + + [FieldOffset(0)] + public MyStruct s; + + [FieldOffset(0)] + [NativeTypeName("short[4]")] + public _buffer_e__FixedBuffer buffer; + + [InlineArray(4)] + public partial struct _buffer_e__FixedBuffer + { + public short e0; + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Compatible.xml new file mode 100644 index 00000000..02caefec --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Compatible.xml @@ -0,0 +1,62 @@ + + + + + + short + + + + + short + + + short + + + short + + + _Anonymous_e__Union + + + ref short + + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->a; + } + + + + ref MyStruct + + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->s; + } + + + + ref short + + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->buffer[0]; + } + + + + + short + + + MyStruct + + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Default.xml new file mode 100644 index 00000000..1f4b335c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Default.xml @@ -0,0 +1,59 @@ + + + + + + short + + + + + short + + + short + + + short + + + _Anonymous_e__Union + + + ref short + + return ref Anonymous.a; + + + + ref MyStruct + + return ref Anonymous.s; + + + + Span<short> + + return Anonymous.buffer; + + + + + short + + + MyStruct + + + short + + + InlineArray(4) + + short + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Latest.xml new file mode 100644 index 00000000..1f4b335c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Latest.xml @@ -0,0 +1,59 @@ + + + + + + short + + + + + short + + + short + + + short + + + _Anonymous_e__Union + + + ref short + + return ref Anonymous.a; + + + + ref MyStruct + + return ref Anonymous.s; + + + + Span<short> + + return Anonymous.buffer; + + + + + short + + + MyStruct + + + short + + + InlineArray(4) + + short + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Preview.xml new file mode 100644 index 00000000..1f4b335c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousTest_short_5Fshort_5F11_5F5.Xml.Preview.xml @@ -0,0 +1,59 @@ + + + + + + short + + + + + short + + + short + + + short + + + _Anonymous_e__Union + + + ref short + + return ref Anonymous.a; + + + + ref MyStruct + + return ref Anonymous.s; + + + + Span<short> + + return Anonymous.buffer; + + + + + short + + + MyStruct + + + short + + + InlineArray(4) + + short + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Compatible.cs new file mode 100644 index 00000000..05a2923a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Compatible.cs @@ -0,0 +1,115 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + public int x; + + [FieldOffset(0)] + public int y; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L6_C5")] + public _Anonymous_e__Union Anonymous; + + public ref int z + { + get + { + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->z; + } + } + } + + public ref int w + { + get + { + fixed (_Anonymous_e__Union._Anonymous1_e__Union* pField = &Anonymous.Anonymous1) + { + return ref pField->w; + } + } + } + + public int o0_b0_16 + { + get + { + return Anonymous.Anonymous1.o0_b0_16; + } + + set + { + Anonymous.Anonymous1.o0_b0_16 = value; + } + } + + public int o0_b16_4 + { + get + { + return Anonymous.Anonymous1.o0_b16_4; + } + + set + { + Anonymous.Anonymous1.o0_b16_4 = value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public int z; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C9")] + public _Anonymous1_e__Union Anonymous1; + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous1_e__Union + { + [FieldOffset(0)] + public int w; + + [FieldOffset(0)] + public int _bitfield; + + [NativeTypeName("int : 16")] + public int o0_b0_16 + { + get + { + return (_bitfield << 16) >> 16; + } + + set + { + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + } + } + + [NativeTypeName("int : 4")] + public int o0_b16_4 + { + get + { + return (_bitfield << 12) >> 28; + } + + set + { + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Default.cs new file mode 100644 index 00000000..f535b706 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Default.cs @@ -0,0 +1,112 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int x; + + [FieldOffset(0)] + public int y; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L6_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref int z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref int w + { + get + { + return ref Anonymous.Anonymous1.w; + } + } + + public int o0_b0_16 + { + readonly get + { + return Anonymous.Anonymous1.o0_b0_16; + } + + set + { + Anonymous.Anonymous1.o0_b0_16 = value; + } + } + + public int o0_b16_4 + { + readonly get + { + return Anonymous.Anonymous1.o0_b16_4; + } + + set + { + Anonymous.Anonymous1.o0_b16_4 = value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public int z; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C9")] + public _Anonymous1_e__Union Anonymous1; + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous1_e__Union + { + [FieldOffset(0)] + public int w; + + [FieldOffset(0)] + public int _bitfield; + + [NativeTypeName("int : 16")] + public int o0_b0_16 + { + readonly get + { + return (_bitfield << 16) >> 16; + } + + set + { + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + } + } + + [NativeTypeName("int : 4")] + public int o0_b16_4 + { + readonly get + { + return (_bitfield << 12) >> 28; + } + + set + { + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Latest.cs new file mode 100644 index 00000000..f535b706 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Latest.cs @@ -0,0 +1,112 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int x; + + [FieldOffset(0)] + public int y; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L6_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref int z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref int w + { + get + { + return ref Anonymous.Anonymous1.w; + } + } + + public int o0_b0_16 + { + readonly get + { + return Anonymous.Anonymous1.o0_b0_16; + } + + set + { + Anonymous.Anonymous1.o0_b0_16 = value; + } + } + + public int o0_b16_4 + { + readonly get + { + return Anonymous.Anonymous1.o0_b16_4; + } + + set + { + Anonymous.Anonymous1.o0_b16_4 = value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public int z; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C9")] + public _Anonymous1_e__Union Anonymous1; + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous1_e__Union + { + [FieldOffset(0)] + public int w; + + [FieldOffset(0)] + public int _bitfield; + + [NativeTypeName("int : 16")] + public int o0_b0_16 + { + readonly get + { + return (_bitfield << 16) >> 16; + } + + set + { + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + } + } + + [NativeTypeName("int : 4")] + public int o0_b16_4 + { + readonly get + { + return (_bitfield << 12) >> 28; + } + + set + { + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Preview.cs new file mode 100644 index 00000000..f535b706 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.CSharp.Preview.cs @@ -0,0 +1,112 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int x; + + [FieldOffset(0)] + public int y; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L6_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref int z + { + get + { + return ref Anonymous.z; + } + } + + [UnscopedRef] + public ref int w + { + get + { + return ref Anonymous.Anonymous1.w; + } + } + + public int o0_b0_16 + { + readonly get + { + return Anonymous.Anonymous1.o0_b0_16; + } + + set + { + Anonymous.Anonymous1.o0_b0_16 = value; + } + } + + public int o0_b16_4 + { + readonly get + { + return Anonymous.Anonymous1.o0_b16_4; + } + + set + { + Anonymous.Anonymous1.o0_b16_4 = value; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public int z; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L10_C9")] + public _Anonymous1_e__Union Anonymous1; + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous1_e__Union + { + [FieldOffset(0)] + public int w; + + [FieldOffset(0)] + public int _bitfield; + + [NativeTypeName("int : 16")] + public int o0_b0_16 + { + readonly get + { + return (_bitfield << 16) >> 16; + } + + set + { + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + } + } + + [NativeTypeName("int : 4")] + public int o0_b16_4 + { + readonly get + { + return (_bitfield << 12) >> 28; + } + + set + { + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Compatible.xml new file mode 100644 index 00000000..42102cfa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Compatible.xml @@ -0,0 +1,88 @@ + + + + + + int + + + int + + + _Anonymous_e__Union + + + ref int + + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->z; + } + + + + ref int + + fixed (_Anonymous_e__Union._Anonymous1_e__Union* pField = &Anonymous.Anonymous1) + { + return ref pField->w; + } + + + + int + + return Anonymous.Anonymous1.o0_b0_16; + + + Anonymous.Anonymous1.o0_b0_16 = value; + + + + int + + return Anonymous.Anonymous1.o0_b16_4; + + + Anonymous.Anonymous1.o0_b16_4 = value; + + + + + int + + + _Anonymous1_e__Union + + + + int + + + int + + + int + + return (_bitfield << 16) >> 16; + + + + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + + + + int + + return (_bitfield << 12) >> 28; + + + + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Default.xml new file mode 100644 index 00000000..dbf5fa7a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Default.xml @@ -0,0 +1,82 @@ + + + + + + int + + + int + + + _Anonymous_e__Union + + + ref int + + return ref Anonymous.z; + + + + ref int + + return ref Anonymous.Anonymous1.w; + + + + int + + return Anonymous.Anonymous1.o0_b0_16; + + + Anonymous.Anonymous1.o0_b0_16 = value; + + + + int + + return Anonymous.Anonymous1.o0_b16_4; + + + Anonymous.Anonymous1.o0_b16_4 = value; + + + + + int + + + _Anonymous1_e__Union + + + + int + + + int + + + int + + return (_bitfield << 16) >> 16; + + + + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + + + + int + + return (_bitfield << 12) >> 28; + + + + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Latest.xml new file mode 100644 index 00000000..dbf5fa7a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Latest.xml @@ -0,0 +1,82 @@ + + + + + + int + + + int + + + _Anonymous_e__Union + + + ref int + + return ref Anonymous.z; + + + + ref int + + return ref Anonymous.Anonymous1.w; + + + + int + + return Anonymous.Anonymous1.o0_b0_16; + + + Anonymous.Anonymous1.o0_b0_16 = value; + + + + int + + return Anonymous.Anonymous1.o0_b16_4; + + + Anonymous.Anonymous1.o0_b16_4 = value; + + + + + int + + + _Anonymous1_e__Union + + + + int + + + int + + + int + + return (_bitfield << 16) >> 16; + + + + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + + + + int + + return (_bitfield << 12) >> 28; + + + + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Preview.xml new file mode 100644 index 00000000..dbf5fa7a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedAnonymousWithBitfieldTest.Xml.Preview.xml @@ -0,0 +1,82 @@ + + + + + + int + + + int + + + _Anonymous_e__Union + + + ref int + + return ref Anonymous.z; + + + + ref int + + return ref Anonymous.Anonymous1.w; + + + + int + + return Anonymous.Anonymous1.o0_b0_16; + + + Anonymous.Anonymous1.o0_b0_16 = value; + + + + int + + return Anonymous.Anonymous1.o0_b16_4; + + + Anonymous.Anonymous1.o0_b16_4 = value; + + + + + int + + + _Anonymous1_e__Union + + + + int + + + int + + + int + + return (_bitfield << 16) >> 16; + + + + _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); + + + + int + + return (_bitfield << 12) >> 28; + + + + _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_double_5Fdouble.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_double_5Fdouble.CSharp.cs new file mode 100644 index 00000000..9105b91f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_double_5Fdouble.CSharp.cs @@ -0,0 +1,33 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double r; + + [FieldOffset(0)] + public double g; + + [FieldOffset(0)] + public double b; + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyNestedUnion + { + [FieldOffset(0)] + public double r; + + [FieldOffset(0)] + public double g; + + [FieldOffset(0)] + public double b; + + [FieldOffset(0)] + public double a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_double_5Fdouble.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_double_5Fdouble.Xml.xml new file mode 100644 index 00000000..e052ae72 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_double_5Fdouble.Xml.xml @@ -0,0 +1,30 @@ + + + + + + double + + + double + + + double + + + + double + + + double + + + double + + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_float_5Ffloat.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_float_5Ffloat.CSharp.cs new file mode 100644 index 00000000..004f4457 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_float_5Ffloat.CSharp.cs @@ -0,0 +1,33 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float r; + + [FieldOffset(0)] + public float g; + + [FieldOffset(0)] + public float b; + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyNestedUnion + { + [FieldOffset(0)] + public float r; + + [FieldOffset(0)] + public float g; + + [FieldOffset(0)] + public float b; + + [FieldOffset(0)] + public float a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_float_5Ffloat.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_float_5Ffloat.Xml.xml new file mode 100644 index 00000000..65d96f36 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_float_5Ffloat.Xml.xml @@ -0,0 +1,30 @@ + + + + + + float + + + float + + + float + + + + float + + + float + + + float + + + float + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_int_5Fint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_int_5Fint.CSharp.cs new file mode 100644 index 00000000..8323fd11 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_int_5Fint.CSharp.cs @@ -0,0 +1,33 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int r; + + [FieldOffset(0)] + public int g; + + [FieldOffset(0)] + public int b; + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyNestedUnion + { + [FieldOffset(0)] + public int r; + + [FieldOffset(0)] + public int g; + + [FieldOffset(0)] + public int b; + + [FieldOffset(0)] + public int a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_int_5Fint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_int_5Fint.Xml.xml new file mode 100644 index 00000000..067630a9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_int_5Fint.Xml.xml @@ -0,0 +1,30 @@ + + + + + + int + + + int + + + int + + + + int + + + int + + + int + + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_short_5Fshort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_short_5Fshort.CSharp.cs new file mode 100644 index 00000000..505ec6b2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_short_5Fshort.CSharp.cs @@ -0,0 +1,33 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short r; + + [FieldOffset(0)] + public short g; + + [FieldOffset(0)] + public short b; + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyNestedUnion + { + [FieldOffset(0)] + public short r; + + [FieldOffset(0)] + public short g; + + [FieldOffset(0)] + public short b; + + [FieldOffset(0)] + public short a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_short_5Fshort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_short_5Fshort.Xml.xml new file mode 100644 index 00000000..168e23b2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedTest_short_5Fshort.Xml.xml @@ -0,0 +1,30 @@ + + + + + + short + + + short + + + short + + + + short + + + short + + + short + + + short + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs new file mode 100644 index 00000000..95859d81 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs @@ -0,0 +1,40 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte r; + + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte g; + + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte b; + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyNestedUnion + { + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte r; + + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte g; + + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte b; + + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.Xml.xml new file mode 100644 index 00000000..e2180b02 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_bool_5Fbyte.Xml.xml @@ -0,0 +1,30 @@ + + + + + + byte + + + byte + + + byte + + + + byte + + + byte + + + byte + + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs new file mode 100644 index 00000000..36d16ac1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs @@ -0,0 +1,40 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long")] + public long r; + + [FieldOffset(0)] + [NativeTypeName("long long")] + public long g; + + [FieldOffset(0)] + [NativeTypeName("long long")] + public long b; + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyNestedUnion + { + [FieldOffset(0)] + [NativeTypeName("long long")] + public long r; + + [FieldOffset(0)] + [NativeTypeName("long long")] + public long g; + + [FieldOffset(0)] + [NativeTypeName("long long")] + public long b; + + [FieldOffset(0)] + [NativeTypeName("long long")] + public long a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.Xml.xml new file mode 100644 index 00000000..9b168476 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_long_20long_5Flong.Xml.xml @@ -0,0 +1,30 @@ + + + + + + long + + + long + + + long + + + + long + + + long + + + long + + + long + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs new file mode 100644 index 00000000..32407748 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs @@ -0,0 +1,40 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte r; + + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte g; + + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte b; + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyNestedUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte r; + + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte g; + + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte b; + + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml new file mode 100644 index 00000000..c8fbea89 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml @@ -0,0 +1,30 @@ + + + + + + sbyte + + + sbyte + + + sbyte + + + + sbyte + + + sbyte + + + sbyte + + + sbyte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs new file mode 100644 index 00000000..d1f27b07 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs @@ -0,0 +1,40 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte r; + + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte g; + + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte b; + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyNestedUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte r; + + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte g; + + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte b; + + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml new file mode 100644 index 00000000..c5fa92ab --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml @@ -0,0 +1,30 @@ + + + + + + byte + + + byte + + + byte + + + + byte + + + byte + + + byte + + + byte + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs new file mode 100644 index 00000000..93ea852a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs @@ -0,0 +1,40 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint r; + + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint g; + + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint b; + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyNestedUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint r; + + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint g; + + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint b; + + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml new file mode 100644 index 00000000..3389a7f7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml @@ -0,0 +1,30 @@ + + + + + + uint + + + uint + + + uint + + + + uint + + + uint + + + uint + + + uint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs new file mode 100644 index 00000000..e109fd75 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs @@ -0,0 +1,40 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong r; + + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong g; + + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong b; + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyNestedUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong r; + + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong g; + + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong b; + + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml new file mode 100644 index 00000000..af782941 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml @@ -0,0 +1,30 @@ + + + + + + ulong + + + ulong + + + ulong + + + + ulong + + + ulong + + + ulong + + + ulong + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs new file mode 100644 index 00000000..8cb01d68 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs @@ -0,0 +1,40 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort r; + + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort g; + + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort b; + + [StructLayout(LayoutKind.Explicit)] + public partial struct MyNestedUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort r; + + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort g; + + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort b; + + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml new file mode 100644 index 00000000..cd3df1c8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NestedWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml @@ -0,0 +1,30 @@ + + + + + + ushort + + + ushort + + + ushort + + + + ushort + + + ushort + + + ushort + + + ushort + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NewKeywordTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NewKeywordTest.CSharp.cs new file mode 100644 index 00000000..6318f6f4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NewKeywordTest.CSharp.cs @@ -0,0 +1,29 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public new int Equals; + + [FieldOffset(0)] + public int Dispose; + + [FieldOffset(0)] + public new int GetHashCode; + + [FieldOffset(0)] + public new int GetType; + + [FieldOffset(0)] + public new int MemberwiseClone; + + [FieldOffset(0)] + public new int ReferenceEquals; + + [FieldOffset(0)] + public new int ToString; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NewKeywordTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NewKeywordTest.Xml.xml new file mode 100644 index 00000000..506b9fed --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NewKeywordTest.Xml.xml @@ -0,0 +1,28 @@ + + + + + + int + + + int + + + int + + + int + + + int + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NoDefinitionTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NoDefinitionTest.CSharp.cs new file mode 100644 index 00000000..05febc9b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NoDefinitionTest.CSharp.cs @@ -0,0 +1,9 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NoDefinitionTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NoDefinitionTest.Xml.xml new file mode 100644 index 00000000..269a2ea0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/NoDefinitionTest.Xml.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfTest.CSharp.cs new file mode 100644 index 00000000..e0cf22c5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfTest.CSharp.cs @@ -0,0 +1,14 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct example_s + { + [FieldOffset(0)] + public example_s* next; + + [FieldOffset(0)] + public void* data; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfTest.Xml.xml new file mode 100644 index 00000000..eae07465 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfTest.Xml.xml @@ -0,0 +1,13 @@ + + + + + + example_s* + + + void* + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfViaTypedefTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfViaTypedefTest.CSharp.cs new file mode 100644 index 00000000..911f6f89 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfViaTypedefTest.CSharp.cs @@ -0,0 +1,15 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct example_s + { + [FieldOffset(0)] + [NativeTypeName("example_t *")] + public example_s* next; + + [FieldOffset(0)] + public void* data; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfViaTypedefTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfViaTypedefTest.Xml.xml new file mode 100644 index 00000000..10212799 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/PointerToSelfViaTypedefTest.Xml.xml @@ -0,0 +1,13 @@ + + + + + + example_s* + + + void* + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Compatible.cs new file mode 100644 index 00000000..d72467af --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Compatible.cs @@ -0,0 +1,39 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct MyUnion + { + [FieldOffset(0)] + public double r; + + [FieldOffset(0)] + public double g; + + [FieldOffset(0)] + public double b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C5")] + public _Anonymous_e__Union Anonymous; + + public ref double a + { + get + { + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->a; + } + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public double a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Default.cs new file mode 100644 index 00000000..320dbb0a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Default.cs @@ -0,0 +1,38 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double r; + + [FieldOffset(0)] + public double g; + + [FieldOffset(0)] + public double b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref double a + { + get + { + return ref Anonymous.a; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public double a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Latest.cs new file mode 100644 index 00000000..320dbb0a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Latest.cs @@ -0,0 +1,38 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double r; + + [FieldOffset(0)] + public double g; + + [FieldOffset(0)] + public double b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref double a + { + get + { + return ref Anonymous.a; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public double a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Preview.cs new file mode 100644 index 00000000..320dbb0a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.CSharp.Preview.cs @@ -0,0 +1,38 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double r; + + [FieldOffset(0)] + public double g; + + [FieldOffset(0)] + public double b; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C5")] + public _Anonymous_e__Union Anonymous; + + [UnscopedRef] + public ref double a + { + get + { + return ref Anonymous.a; + } + } + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + public double a; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Compatible.xml new file mode 100644 index 00000000..fd320494 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Compatible.xml @@ -0,0 +1,33 @@ + + + + + + double + + + double + + + double + + + _Anonymous_e__Union + + + ref double + + fixed (_Anonymous_e__Union* pField = &Anonymous) + { + return ref pField->a; + } + + + + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Default.xml new file mode 100644 index 00000000..3897ae23 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Default.xml @@ -0,0 +1,30 @@ + + + + + + double + + + double + + + double + + + _Anonymous_e__Union + + + ref double + + return ref Anonymous.a; + + + + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Latest.xml new file mode 100644 index 00000000..3897ae23 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Latest.xml @@ -0,0 +1,30 @@ + + + + + + double + + + double + + + double + + + _Anonymous_e__Union + + + ref double + + return ref Anonymous.a; + + + + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Preview.xml new file mode 100644 index 00000000..3897ae23 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapNestedAnonymousTest.Xml.Preview.xml @@ -0,0 +1,30 @@ + + + + + + double + + + double + + + double + + + _Anonymous_e__Union + + + ref double + + return ref Anonymous.a; + + + + + double + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapTest.CSharp.cs new file mode 100644 index 00000000..05febc9b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapTest.CSharp.cs @@ -0,0 +1,9 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapTest.Xml.xml new file mode 100644 index 00000000..269a2ea0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/RemapTest.Xml.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionPointerTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionPointerTest.CSharp.cs new file mode 100644 index 00000000..05febc9b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionPointerTest.CSharp.cs @@ -0,0 +1,9 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionPointerTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionPointerTest.Xml.xml new file mode 100644 index 00000000..269a2ea0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionPointerTest.Xml.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_double_5Fdouble.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_double_5Fdouble.CSharp.cs new file mode 100644 index 00000000..992158fa --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_double_5Fdouble.CSharp.cs @@ -0,0 +1,17 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public double r; + + [FieldOffset(0)] + public double g; + + [FieldOffset(0)] + public double b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_double_5Fdouble.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_double_5Fdouble.Xml.xml new file mode 100644 index 00000000..35fcc2b6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_double_5Fdouble.Xml.xml @@ -0,0 +1,16 @@ + + + + + + double + + + double + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_float_5Ffloat.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_float_5Ffloat.CSharp.cs new file mode 100644 index 00000000..f08785b8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_float_5Ffloat.CSharp.cs @@ -0,0 +1,17 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public float r; + + [FieldOffset(0)] + public float g; + + [FieldOffset(0)] + public float b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_float_5Ffloat.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_float_5Ffloat.Xml.xml new file mode 100644 index 00000000..9c2e176d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_float_5Ffloat.Xml.xml @@ -0,0 +1,16 @@ + + + + + + float + + + float + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_int_5Fint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_int_5Fint.CSharp.cs new file mode 100644 index 00000000..efdc9f8a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_int_5Fint.CSharp.cs @@ -0,0 +1,17 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public int r; + + [FieldOffset(0)] + public int g; + + [FieldOffset(0)] + public int b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_int_5Fint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_int_5Fint.Xml.xml new file mode 100644 index 00000000..5d7c9ff3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_int_5Fint.Xml.xml @@ -0,0 +1,16 @@ + + + + + + int + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_short_5Fshort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_short_5Fshort.CSharp.cs new file mode 100644 index 00000000..e7369e88 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_short_5Fshort.CSharp.cs @@ -0,0 +1,17 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + public short r; + + [FieldOffset(0)] + public short g; + + [FieldOffset(0)] + public short b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_short_5Fshort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_short_5Fshort.Xml.xml new file mode 100644 index 00000000..11f5b08d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionTest_short_5Fshort.Xml.xml @@ -0,0 +1,16 @@ + + + + + + short + + + short + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs new file mode 100644 index 00000000..83eef48e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte r; + + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte g; + + [FieldOffset(0)] + [NativeTypeName("bool")] + public byte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.Xml.xml new file mode 100644 index 00000000..94027b07 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_bool_5Fbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + byte + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs new file mode 100644 index 00000000..7458cdde --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("long long")] + public long r; + + [FieldOffset(0)] + [NativeTypeName("long long")] + public long g; + + [FieldOffset(0)] + [NativeTypeName("long long")] + public long b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.Xml.xml new file mode 100644 index 00000000..478b8af8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_long_20long_5Flong.Xml.xml @@ -0,0 +1,16 @@ + + + + + + long + + + long + + + long + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs new file mode 100644 index 00000000..9f04efdb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte r; + + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte g; + + [FieldOffset(0)] + [NativeTypeName("signed char")] + public sbyte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml new file mode 100644 index 00000000..0b2b4a22 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_signed_20char_5Fsbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + sbyte + + + sbyte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs new file mode 100644 index 00000000..2e955545 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte r; + + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte g; + + [FieldOffset(0)] + [NativeTypeName("unsigned char")] + public byte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml new file mode 100644 index 00000000..b6473799 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20char_5Fbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + byte + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs new file mode 100644 index 00000000..339b1f62 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint r; + + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint g; + + [FieldOffset(0)] + [NativeTypeName("unsigned int")] + public uint b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml new file mode 100644 index 00000000..ac1fc227 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20int_5Fuint.Xml.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + uint + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs new file mode 100644 index 00000000..71b3faa2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong r; + + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong g; + + [FieldOffset(0)] + [NativeTypeName("unsigned long long")] + public ulong b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml new file mode 100644 index 00000000..07911724 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20long_20long_5Fulong.Xml.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + ulong + + + ulong + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs new file mode 100644 index 00000000..5b8b0295 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort r; + + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort g; + + [FieldOffset(0)] + [NativeTypeName("unsigned short")] + public ushort b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml new file mode 100644 index 00000000..7f601889 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/SkipNonDefinitionWithNativeTypeNameTest_unsigned_20short_5Fushort.Xml.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + ushort + + + ushort + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_bool_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_bool_5Fbyte.CSharp.cs new file mode 100644 index 00000000..b25e13f6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_bool_5Fbyte.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public byte r; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public byte g; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public byte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_bool_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_bool_5Fbyte.Xml.xml new file mode 100644 index 00000000..31816fdd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_bool_5Fbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + byte + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_double_5Fdouble.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_double_5Fdouble.CSharp.cs new file mode 100644 index 00000000..6e15977d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_double_5Fdouble.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public double r; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public double g; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public double b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_double_5Fdouble.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_double_5Fdouble.Xml.xml new file mode 100644 index 00000000..38238ac2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_double_5Fdouble.Xml.xml @@ -0,0 +1,16 @@ + + + + + + double + + + double + + + double + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_float_5Ffloat.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_float_5Ffloat.CSharp.cs new file mode 100644 index 00000000..ba5dc575 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_float_5Ffloat.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public float r; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public float g; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public float b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_float_5Ffloat.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_float_5Ffloat.Xml.xml new file mode 100644 index 00000000..4ce5abcc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_float_5Ffloat.Xml.xml @@ -0,0 +1,16 @@ + + + + + + float + + + float + + + float + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_int_5Fint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_int_5Fint.CSharp.cs new file mode 100644 index 00000000..4b5466ef --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_int_5Fint.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public int r; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public int g; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public int b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_int_5Fint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_int_5Fint.Xml.xml new file mode 100644 index 00000000..97ee5ef7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_int_5Fint.Xml.xml @@ -0,0 +1,16 @@ + + + + + + int + + + int + + + int + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_long_20long_5Flong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_long_20long_5Flong.CSharp.cs new file mode 100644 index 00000000..db92bb21 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_long_20long_5Flong.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public long r; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public long g; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public long b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_long_20long_5Flong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_long_20long_5Flong.Xml.xml new file mode 100644 index 00000000..b15f5749 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_long_20long_5Flong.Xml.xml @@ -0,0 +1,16 @@ + + + + + + long + + + long + + + long + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_short_5Fshort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_short_5Fshort.CSharp.cs new file mode 100644 index 00000000..e0839f11 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_short_5Fshort.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public short r; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public short g; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public short b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_short_5Fshort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_short_5Fshort.Xml.xml new file mode 100644 index 00000000..697e4885 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_short_5Fshort.Xml.xml @@ -0,0 +1,16 @@ + + + + + + short + + + short + + + short + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_signed_20char_5Fsbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_signed_20char_5Fsbyte.CSharp.cs new file mode 100644 index 00000000..acfc35ff --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_signed_20char_5Fsbyte.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public sbyte r; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public sbyte g; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public sbyte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_signed_20char_5Fsbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_signed_20char_5Fsbyte.Xml.xml new file mode 100644 index 00000000..ea001784 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_signed_20char_5Fsbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + sbyte + + + sbyte + + + sbyte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20char_5Fbyte.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20char_5Fbyte.CSharp.cs new file mode 100644 index 00000000..b25e13f6 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20char_5Fbyte.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public byte r; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public byte g; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public byte b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20char_5Fbyte.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20char_5Fbyte.Xml.xml new file mode 100644 index 00000000..31816fdd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20char_5Fbyte.Xml.xml @@ -0,0 +1,16 @@ + + + + + + byte + + + byte + + + byte + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20int_5Fuint.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20int_5Fuint.CSharp.cs new file mode 100644 index 00000000..06bd8fe5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20int_5Fuint.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public uint r; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public uint g; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public uint b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20int_5Fuint.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20int_5Fuint.Xml.xml new file mode 100644 index 00000000..4c9780f5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20int_5Fuint.Xml.xml @@ -0,0 +1,16 @@ + + + + + + uint + + + uint + + + uint + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.CSharp.cs new file mode 100644 index 00000000..87dbd7e1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public ulong r; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public ulong g; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public ulong b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.Xml.xml new file mode 100644 index 00000000..81a2de66 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20long_20long_5Fulong.Xml.xml @@ -0,0 +1,16 @@ + + + + + + ulong + + + ulong + + + ulong + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20short_5Fushort.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20short_5Fushort.CSharp.cs new file mode 100644 index 00000000..9d1283f8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20short_5Fushort.CSharp.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct MyUnion + { + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public ushort r; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public ushort g; + + [FieldOffset(0)] + [NativeTypeName("MyTypedefAlias")] + public ushort b; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20short_5Fushort.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20short_5Fushort.Xml.xml new file mode 100644 index 00000000..4fe24e7c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/TypedefTest_unsigned_20short_5Fushort.Xml.xml @@ -0,0 +1,16 @@ + + + + + + ushort + + + ushort + + + ushort + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..9875cef1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Compatible.Unix.cs @@ -0,0 +1,100 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct _MY_UNION + { + [FieldOffset(0)] + [NativeTypeName("long[2]")] + public _AsArray_e__FixedBuffer AsArray; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L4_C5")] + public _Anonymous_e__Struct Anonymous; + + public ref IntPtr First + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->First; + } + } + } + + public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A + { + get + { + fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) + { + return ref pField->A; + } + } + } + + public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B + { + get + { + fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) + { + return ref pField->B; + } + } + } + + public unsafe partial struct _Anonymous_e__Struct + { + [NativeTypeName("long")] + public IntPtr First; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C9")] + public _Anonymous_e__Union Anonymous; + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L9_C13")] + public _A_e__Struct A; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C13")] + public _B_e__Struct B; + + public partial struct _A_e__Struct + { + [NativeTypeName("long")] + public IntPtr Second; + } + + public partial struct _B_e__Struct + { + [NativeTypeName("long")] + public IntPtr Second; + } + } + } + + public partial struct _AsArray_e__FixedBuffer + { + public IntPtr e0; + public IntPtr e1; + + public unsafe ref IntPtr this[int index] + { + get + { + fixed (IntPtr* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..d1d08dcf --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Compatible.Windows.cs @@ -0,0 +1,82 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct _MY_UNION + { + [FieldOffset(0)] + [NativeTypeName("long[2]")] + public fixed int AsArray[2]; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L4_C5")] + public _Anonymous_e__Struct Anonymous; + + public ref int First + { + get + { + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->First; + } + } + } + + public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A + { + get + { + fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) + { + return ref pField->A; + } + } + } + + public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B + { + get + { + fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) + { + return ref pField->B; + } + } + } + + public unsafe partial struct _Anonymous_e__Struct + { + [NativeTypeName("long")] + public int First; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C9")] + public _Anonymous_e__Union Anonymous; + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L9_C13")] + public _A_e__Struct A; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C13")] + public _B_e__Struct B; + + public partial struct _A_e__Struct + { + [NativeTypeName("long")] + public int Second; + } + + public partial struct _B_e__Struct + { + [NativeTypeName("long")] + public int Second; + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Default.Unix.cs new file mode 100644 index 00000000..abe086b3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Default.Unix.cs @@ -0,0 +1,84 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct _MY_UNION + { + [FieldOffset(0)] + [NativeTypeName("long[2]")] + public _AsArray_e__FixedBuffer AsArray; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L4_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref nint First + { + get + { + return ref Anonymous.First; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A + { + get + { + return ref Anonymous.Anonymous.A; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B + { + get + { + return ref Anonymous.Anonymous.B; + } + } + + public partial struct _Anonymous_e__Struct + { + [NativeTypeName("long")] + public nint First; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C9")] + public _Anonymous_e__Union Anonymous; + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L9_C13")] + public _A_e__Struct A; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C13")] + public _B_e__Struct B; + + public partial struct _A_e__Struct + { + [NativeTypeName("long")] + public nint Second; + } + + public partial struct _B_e__Struct + { + [NativeTypeName("long")] + public nint Second; + } + } + } + + [InlineArray(2)] + public partial struct _AsArray_e__FixedBuffer + { + public nint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Default.Windows.cs new file mode 100644 index 00000000..0b542be9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Default.Windows.cs @@ -0,0 +1,84 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct _MY_UNION + { + [FieldOffset(0)] + [NativeTypeName("long[2]")] + public _AsArray_e__FixedBuffer AsArray; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L4_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int First + { + get + { + return ref Anonymous.First; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A + { + get + { + return ref Anonymous.Anonymous.A; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B + { + get + { + return ref Anonymous.Anonymous.B; + } + } + + public partial struct _Anonymous_e__Struct + { + [NativeTypeName("long")] + public int First; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C9")] + public _Anonymous_e__Union Anonymous; + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L9_C13")] + public _A_e__Struct A; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C13")] + public _B_e__Struct B; + + public partial struct _A_e__Struct + { + [NativeTypeName("long")] + public int Second; + } + + public partial struct _B_e__Struct + { + [NativeTypeName("long")] + public int Second; + } + } + } + + [InlineArray(2)] + public partial struct _AsArray_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..abe086b3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Latest.Unix.cs @@ -0,0 +1,84 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct _MY_UNION + { + [FieldOffset(0)] + [NativeTypeName("long[2]")] + public _AsArray_e__FixedBuffer AsArray; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L4_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref nint First + { + get + { + return ref Anonymous.First; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A + { + get + { + return ref Anonymous.Anonymous.A; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B + { + get + { + return ref Anonymous.Anonymous.B; + } + } + + public partial struct _Anonymous_e__Struct + { + [NativeTypeName("long")] + public nint First; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C9")] + public _Anonymous_e__Union Anonymous; + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L9_C13")] + public _A_e__Struct A; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C13")] + public _B_e__Struct B; + + public partial struct _A_e__Struct + { + [NativeTypeName("long")] + public nint Second; + } + + public partial struct _B_e__Struct + { + [NativeTypeName("long")] + public nint Second; + } + } + } + + [InlineArray(2)] + public partial struct _AsArray_e__FixedBuffer + { + public nint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..0b542be9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Latest.Windows.cs @@ -0,0 +1,84 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct _MY_UNION + { + [FieldOffset(0)] + [NativeTypeName("long[2]")] + public _AsArray_e__FixedBuffer AsArray; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L4_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int First + { + get + { + return ref Anonymous.First; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A + { + get + { + return ref Anonymous.Anonymous.A; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B + { + get + { + return ref Anonymous.Anonymous.B; + } + } + + public partial struct _Anonymous_e__Struct + { + [NativeTypeName("long")] + public int First; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C9")] + public _Anonymous_e__Union Anonymous; + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L9_C13")] + public _A_e__Struct A; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C13")] + public _B_e__Struct B; + + public partial struct _A_e__Struct + { + [NativeTypeName("long")] + public int Second; + } + + public partial struct _B_e__Struct + { + [NativeTypeName("long")] + public int Second; + } + } + } + + [InlineArray(2)] + public partial struct _AsArray_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..abe086b3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Preview.Unix.cs @@ -0,0 +1,84 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct _MY_UNION + { + [FieldOffset(0)] + [NativeTypeName("long[2]")] + public _AsArray_e__FixedBuffer AsArray; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L4_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref nint First + { + get + { + return ref Anonymous.First; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A + { + get + { + return ref Anonymous.Anonymous.A; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B + { + get + { + return ref Anonymous.Anonymous.B; + } + } + + public partial struct _Anonymous_e__Struct + { + [NativeTypeName("long")] + public nint First; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C9")] + public _Anonymous_e__Union Anonymous; + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L9_C13")] + public _A_e__Struct A; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C13")] + public _B_e__Struct B; + + public partial struct _A_e__Struct + { + [NativeTypeName("long")] + public nint Second; + } + + public partial struct _B_e__Struct + { + [NativeTypeName("long")] + public nint Second; + } + } + } + + [InlineArray(2)] + public partial struct _AsArray_e__FixedBuffer + { + public nint e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..0b542be9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.CSharp.Preview.Windows.cs @@ -0,0 +1,84 @@ +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct _MY_UNION + { + [FieldOffset(0)] + [NativeTypeName("long[2]")] + public _AsArray_e__FixedBuffer AsArray; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L4_C5")] + public _Anonymous_e__Struct Anonymous; + + [UnscopedRef] + public ref int First + { + get + { + return ref Anonymous.First; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A + { + get + { + return ref Anonymous.Anonymous.A; + } + } + + [UnscopedRef] + public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B + { + get + { + return ref Anonymous.Anonymous.B; + } + } + + public partial struct _Anonymous_e__Struct + { + [NativeTypeName("long")] + public int First; + + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L7_C9")] + public _Anonymous_e__Union Anonymous; + + [StructLayout(LayoutKind.Explicit)] + public partial struct _Anonymous_e__Union + { + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L9_C13")] + public _A_e__Struct A; + + [FieldOffset(0)] + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C13")] + public _B_e__Struct B; + + public partial struct _A_e__Struct + { + [NativeTypeName("long")] + public int Second; + } + + public partial struct _B_e__Struct + { + [NativeTypeName("long")] + public int Second; + } + } + } + + [InlineArray(2)] + public partial struct _AsArray_e__FixedBuffer + { + public int e0; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..845c7a32 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Compatible.Unix.xml @@ -0,0 +1,86 @@ + + + + + + IntPtr + + + _Anonymous_e__Struct + + + ref IntPtr + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->First; + } + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct + + fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) + { + return ref pField->A; + } + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct + + fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) + { + return ref pField->B; + } + + + + + IntPtr + + + _Anonymous_e__Union + + + + _A_e__Struct + + + _B_e__Struct + + + + IntPtr + + + + + IntPtr + + + + + + + IntPtr + + + IntPtr + + + ref IntPtr + + int + + + fixed (IntPtr* pThis = &e0) + { + return ref pThis[index]; + } + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Compatible.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Compatible.Windows.xml new file mode 100644 index 00000000..29760292 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Compatible.Windows.xml @@ -0,0 +1,66 @@ + + + + + + int + + + _Anonymous_e__Struct + + + ref int + + fixed (_Anonymous_e__Struct* pField = &Anonymous) + { + return ref pField->First; + } + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct + + fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) + { + return ref pField->A; + } + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct + + fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) + { + return ref pField->B; + } + + + + + int + + + _Anonymous_e__Union + + + + _A_e__Struct + + + _B_e__Struct + + + + int + + + + + int + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Default.Unix.xml new file mode 100644 index 00000000..7065024d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Default.Unix.xml @@ -0,0 +1,63 @@ + + + + + + nint + + + _Anonymous_e__Struct + + + ref nint + + return ref Anonymous.First; + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct + + return ref Anonymous.Anonymous.A; + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct + + return ref Anonymous.Anonymous.B; + + + + + nint + + + _Anonymous_e__Union + + + + _A_e__Struct + + + _B_e__Struct + + + + nint + + + + + nint + + + + + + InlineArray(2) + + nint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Default.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Default.Windows.xml new file mode 100644 index 00000000..4aab4c78 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Default.Windows.xml @@ -0,0 +1,63 @@ + + + + + + int + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.First; + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct + + return ref Anonymous.Anonymous.A; + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct + + return ref Anonymous.Anonymous.B; + + + + + int + + + _Anonymous_e__Union + + + + _A_e__Struct + + + _B_e__Struct + + + + int + + + + + int + + + + + + InlineArray(2) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Latest.Unix.xml new file mode 100644 index 00000000..7065024d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Latest.Unix.xml @@ -0,0 +1,63 @@ + + + + + + nint + + + _Anonymous_e__Struct + + + ref nint + + return ref Anonymous.First; + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct + + return ref Anonymous.Anonymous.A; + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct + + return ref Anonymous.Anonymous.B; + + + + + nint + + + _Anonymous_e__Union + + + + _A_e__Struct + + + _B_e__Struct + + + + nint + + + + + nint + + + + + + InlineArray(2) + + nint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Latest.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Latest.Windows.xml new file mode 100644 index 00000000..4aab4c78 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Latest.Windows.xml @@ -0,0 +1,63 @@ + + + + + + int + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.First; + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct + + return ref Anonymous.Anonymous.A; + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct + + return ref Anonymous.Anonymous.B; + + + + + int + + + _Anonymous_e__Union + + + + _A_e__Struct + + + _B_e__Struct + + + + int + + + + + int + + + + + + InlineArray(2) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Preview.Unix.xml new file mode 100644 index 00000000..7065024d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Preview.Unix.xml @@ -0,0 +1,63 @@ + + + + + + nint + + + _Anonymous_e__Struct + + + ref nint + + return ref Anonymous.First; + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct + + return ref Anonymous.Anonymous.A; + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct + + return ref Anonymous.Anonymous.B; + + + + + nint + + + _Anonymous_e__Union + + + + _A_e__Struct + + + _B_e__Struct + + + + nint + + + + + nint + + + + + + InlineArray(2) + + nint + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Preview.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Preview.Windows.xml new file mode 100644 index 00000000..4aab4c78 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionDeclaration/UnionWithAnonStructWithAnonUnion.Xml.Preview.Windows.xml @@ -0,0 +1,63 @@ + + + + + + int + + + _Anonymous_e__Struct + + + ref int + + return ref Anonymous.First; + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct + + return ref Anonymous.Anonymous.A; + + + + ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct + + return ref Anonymous.Anonymous.B; + + + + + int + + + _Anonymous_e__Union + + + + _A_e__Struct + + + _B_e__Struct + + + + int + + + + + int + + + + + + InlineArray(2) + + int + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_double.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_double.CSharp.cs new file mode 100644 index 00000000..abb7732f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_double.CSharp.cs @@ -0,0 +1,7 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static double MyVariable = 0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_double.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_double.Xml.xml new file mode 100644 index 00000000..7e51277d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_double.Xml.xml @@ -0,0 +1,13 @@ + + + + + + double + + 0 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_float.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_float.CSharp.cs new file mode 100644 index 00000000..9cbc2191 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_float.CSharp.cs @@ -0,0 +1,7 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static float MyVariable = 0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_float.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_float.Xml.xml new file mode 100644 index 00000000..1ca4e4e5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_float.Xml.xml @@ -0,0 +1,13 @@ + + + + + + float + + 0 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_int.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_int.CSharp.cs new file mode 100644 index 00000000..1eed0575 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_int.CSharp.cs @@ -0,0 +1,7 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static int MyVariable = 0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_int.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_int.Xml.xml new file mode 100644 index 00000000..e6b59b13 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_int.Xml.xml @@ -0,0 +1,13 @@ + + + + + + int + + 0 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_short.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_short.CSharp.cs new file mode 100644 index 00000000..2882f6d9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_short.CSharp.cs @@ -0,0 +1,7 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + public static short MyVariable = 0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_short.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_short.Xml.xml new file mode 100644 index 00000000..65a24b02 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicTest_short.Xml.xml @@ -0,0 +1,13 @@ + + + + + + short + + 0 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_long_20long.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_long_20long.CSharp.cs new file mode 100644 index 00000000..1d97ce2d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_long_20long.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("long long")] + public static long MyVariable = 0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_long_20long.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_long_20long.Xml.xml new file mode 100644 index 00000000..670d7921 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_long_20long.Xml.xml @@ -0,0 +1,13 @@ + + + + + + long + + 0 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_signed_20char.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_signed_20char.CSharp.cs new file mode 100644 index 00000000..c9dd9173 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_signed_20char.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("signed char")] + public static sbyte MyVariable = 0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_signed_20char.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_signed_20char.Xml.xml new file mode 100644 index 00000000..d4a2019c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_signed_20char.Xml.xml @@ -0,0 +1,13 @@ + + + + + + sbyte + + 0 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20char.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20char.CSharp.cs new file mode 100644 index 00000000..49105d39 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20char.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("unsigned char")] + public static byte MyVariable = 0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20char.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20char.Xml.xml new file mode 100644 index 00000000..b153c852 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20char.Xml.xml @@ -0,0 +1,13 @@ + + + + + + byte + + 0 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20int.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20int.CSharp.cs new file mode 100644 index 00000000..c85d6911 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20int.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("unsigned int")] + public static uint MyVariable = 0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20int.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20int.Xml.xml new file mode 100644 index 00000000..b6693fbe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20int.Xml.xml @@ -0,0 +1,13 @@ + + + + + + uint + + 0 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long.CSharp.cs new file mode 100644 index 00000000..4fec43f3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("unsigned long long")] + public static ulong MyVariable = 0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long.Xml.xml new file mode 100644 index 00000000..140dcd7d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20long_20long.Xml.xml @@ -0,0 +1,13 @@ + + + + + + ulong + + 0 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20short.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20short.CSharp.cs new file mode 100644 index 00000000..bb595c05 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20short.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("unsigned short")] + public static ushort MyVariable = 0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20short.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20short.Xml.xml new file mode 100644 index 00000000..978e4ee1 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/BasicWithNativeTypeNameTest_unsigned_20short.Xml.xml @@ -0,0 +1,13 @@ + + + + + + ushort + + 0 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/ConditionalDefineConstTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/ConditionalDefineConstTest.CSharp.cs new file mode 100644 index 00000000..efb078dd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/ConditionalDefineConstTest.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)")] + public const int ADDRESS_IN_USE = unchecked((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/ConditionalDefineConstTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/ConditionalDefineConstTest.Xml.xml new file mode 100644 index 00000000..47c03e60 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/ConditionalDefineConstTest.Xml.xml @@ -0,0 +1,15 @@ + + + + + + int + + + ((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))) + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/GuidMacroTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/GuidMacroTest.CSharp.cs new file mode 100644 index 00000000..0c794ba8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/GuidMacroTest.CSharp.cs @@ -0,0 +1,10 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const GUID")] + public static readonly Guid IID_IUnknown = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/GuidMacroTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/GuidMacroTest.Xml.xml new file mode 100644 index 00000000..6d4ed67b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/GuidMacroTest.Xml.xml @@ -0,0 +1,13 @@ + + + + + + Guid + + new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46) + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0.CSharp.cs new file mode 100644 index 00000000..43dd9231 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 0")] + public const int MyMacro1 = 0; + + [NativeTypeName("#define MyMacro2 MyMacro1")] + public const int MyMacro2 = 0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0.Xml.xml new file mode 100644 index 00000000..141c0496 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0.Xml.xml @@ -0,0 +1,19 @@ + + + + + + int + + 0 + + + + int + + 0 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LL.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LL.CSharp.cs new file mode 100644 index 00000000..98239144 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LL.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 0LL")] + public const long MyMacro1 = 0L; + + [NativeTypeName("#define MyMacro2 MyMacro1")] + public const long MyMacro2 = 0L; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LL.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LL.Xml.xml new file mode 100644 index 00000000..8576fc59 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LL.Xml.xml @@ -0,0 +1,19 @@ + + + + + + long + + 0L + + + + long + + 0L + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LLU.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LLU.CSharp.cs new file mode 100644 index 00000000..dde5c436 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LLU.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 0LLU")] + public const ulong MyMacro1 = 0UL; + + [NativeTypeName("#define MyMacro2 MyMacro1")] + public const ulong MyMacro2 = 0UL; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LLU.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LLU.Xml.xml new file mode 100644 index 00000000..2bf4912c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0LLU.Xml.xml @@ -0,0 +1,19 @@ + + + + + + ulong + + 0UL + + + + ulong + + 0UL + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0U.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0U.CSharp.cs new file mode 100644 index 00000000..781a5d4b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0U.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 0U")] + public const uint MyMacro1 = 0U; + + [NativeTypeName("#define MyMacro2 MyMacro1")] + public const uint MyMacro2 = 0U; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0U.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0U.Xml.xml new file mode 100644 index 00000000..4dc3adbb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0U.Xml.xml @@ -0,0 +1,19 @@ + + + + + + uint + + 0U + + + + uint + + 0U + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0ULL.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0ULL.CSharp.cs new file mode 100644 index 00000000..b290d6b4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0ULL.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 0ULL")] + public const ulong MyMacro1 = 0UL; + + [NativeTypeName("#define MyMacro2 MyMacro1")] + public const ulong MyMacro2 = 0UL; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0ULL.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0ULL.Xml.xml new file mode 100644 index 00000000..2bf4912c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0ULL.Xml.xml @@ -0,0 +1,19 @@ + + + + + + ulong + + 0UL + + + + ulong + + 0UL + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2E0.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2E0.CSharp.cs new file mode 100644 index 00000000..65a3908b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2E0.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 0.0")] + public const double MyMacro1 = 0.0; + + [NativeTypeName("#define MyMacro2 MyMacro1")] + public const double MyMacro2 = 0.0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2E0.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2E0.Xml.xml new file mode 100644 index 00000000..71689801 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2E0.Xml.xml @@ -0,0 +1,19 @@ + + + + + + double + + 0.0 + + + + double + + 0.0 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2Ef.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2Ef.CSharp.cs new file mode 100644 index 00000000..dda65176 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2Ef.CSharp.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 0.f")] + public const float MyMacro1 = 0.0f; + + [NativeTypeName("#define MyMacro2 MyMacro1")] + public const float MyMacro2 = 0.0f; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2Ef.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2Ef.Xml.xml new file mode 100644 index 00000000..83ba30a9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MacroTest_0_2Ef.Xml.xml @@ -0,0 +1,19 @@ + + + + + + float + + 0.0f + + + + float + + 0.0f + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultidimensionlArrayTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultidimensionlArrayTest.CSharp.cs new file mode 100644 index 00000000..873d9a3f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultidimensionlArrayTest.CSharp.cs @@ -0,0 +1,20 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const int[2][2]")] + public static readonly int[][] MyArray = new int[2][] + { + new int[2] + { + 0, + 1, + }, + new int[2] + { + 2, + 3, + }, + }; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultidimensionlArrayTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultidimensionlArrayTest.Xml.xml new file mode 100644 index 00000000..31969fe5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultidimensionlArrayTest.Xml.xml @@ -0,0 +1,25 @@ + + + + + + int[][] + + new int[2][] + { + new int[2] + { + 0, + 1, + }, + new int[2] + { + 2, + 3, + }, + } + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultilineMacroTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultilineMacroTest.CSharp.cs new file mode 100644 index 00000000..eda40d0d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultilineMacroTest.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 0 + \\\n1")] + public const int MyMacro1 = 0 + 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultilineMacroTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultilineMacroTest.Xml.xml new file mode 100644 index 00000000..46bc242b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/MultilineMacroTest.Xml.xml @@ -0,0 +1,13 @@ + + + + + + int + + 0 + 1 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_double.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_double.CSharp.cs new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_double.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_double.Xml.xml new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_float.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_float.CSharp.cs new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_float.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_float.Xml.xml new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_int.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_int.CSharp.cs new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_int.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_int.Xml.xml new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_short.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_short.CSharp.cs new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_short.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/NoInitializerTest_short.Xml.xml new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Compatible.cs new file mode 100644 index 00000000..caf671e4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Compatible.cs @@ -0,0 +1,16 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const char[11]")] + public static ReadOnlySpan MyConst1 => new byte[] { 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }; + + [NativeTypeName("const char *")] + public static byte[] MyConst2 = new byte[] { 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }; + + [NativeTypeName("const char *const")] + public static ReadOnlySpan MyConst3 => new byte[] { 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Default.cs new file mode 100644 index 00000000..1d163657 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const char[11]")] + public static ReadOnlySpan MyConst1 => "Test\0\\\r\n\t\""u8; + + [NativeTypeName("const char *")] + public static byte[] MyConst2 = "Test\0\\\r\n\t\""u8.ToArray(); + + [NativeTypeName("const char *const")] + public static ReadOnlySpan MyConst3 => "Test\0\\\r\n\t\""u8; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Latest.cs new file mode 100644 index 00000000..1d163657 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const char[11]")] + public static ReadOnlySpan MyConst1 => "Test\0\\\r\n\t\""u8; + + [NativeTypeName("const char *")] + public static byte[] MyConst2 = "Test\0\\\r\n\t\""u8.ToArray(); + + [NativeTypeName("const char *const")] + public static ReadOnlySpan MyConst3 => "Test\0\\\r\n\t\""u8; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Preview.cs new file mode 100644 index 00000000..1d163657 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const char[11]")] + public static ReadOnlySpan MyConst1 => "Test\0\\\r\n\t\""u8; + + [NativeTypeName("const char *")] + public static byte[] MyConst2 = "Test\0\\\r\n\t\""u8.ToArray(); + + [NativeTypeName("const char *const")] + public static ReadOnlySpan MyConst3 => "Test\0\\\r\n\t\""u8; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Compatible.xml new file mode 100644 index 00000000..9a7c592b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Compatible.xml @@ -0,0 +1,25 @@ + + + + + + ReadOnlySpan<byte> + + new byte[] { 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 } + + + + byte[] + + new byte[] { 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 } + + + + ReadOnlySpan<byte> + + new byte[] { 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 } + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Default.xml new file mode 100644 index 00000000..d1e476bc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Default.xml @@ -0,0 +1,25 @@ + + + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + byte[] + + "Test\0\\\r\n\t\""u8.ToArray() + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Latest.xml new file mode 100644 index 00000000..d1e476bc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Latest.xml @@ -0,0 +1,25 @@ + + + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + byte[] + + "Test\0\\\r\n\t\""u8.ToArray() + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Preview.xml new file mode 100644 index 00000000..d1e476bc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralConstTest.Xml.Preview.xml @@ -0,0 +1,25 @@ + + + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + byte[] + + "Test\0\\\r\n\t\""u8.ToArray() + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Compatible.cs new file mode 100644 index 00000000..caf671e4 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Compatible.cs @@ -0,0 +1,16 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const char[11]")] + public static ReadOnlySpan MyConst1 => new byte[] { 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }; + + [NativeTypeName("const char *")] + public static byte[] MyConst2 = new byte[] { 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }; + + [NativeTypeName("const char *const")] + public static ReadOnlySpan MyConst3 => new byte[] { 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Default.cs new file mode 100644 index 00000000..1d163657 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Default.cs @@ -0,0 +1,16 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const char[11]")] + public static ReadOnlySpan MyConst1 => "Test\0\\\r\n\t\""u8; + + [NativeTypeName("const char *")] + public static byte[] MyConst2 = "Test\0\\\r\n\t\""u8.ToArray(); + + [NativeTypeName("const char *const")] + public static ReadOnlySpan MyConst3 => "Test\0\\\r\n\t\""u8; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Latest.cs new file mode 100644 index 00000000..1d163657 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Latest.cs @@ -0,0 +1,16 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const char[11]")] + public static ReadOnlySpan MyConst1 => "Test\0\\\r\n\t\""u8; + + [NativeTypeName("const char *")] + public static byte[] MyConst2 = "Test\0\\\r\n\t\""u8.ToArray(); + + [NativeTypeName("const char *const")] + public static ReadOnlySpan MyConst3 => "Test\0\\\r\n\t\""u8; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Preview.cs new file mode 100644 index 00000000..1d163657 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.CSharp.Preview.cs @@ -0,0 +1,16 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const char[11]")] + public static ReadOnlySpan MyConst1 => "Test\0\\\r\n\t\""u8; + + [NativeTypeName("const char *")] + public static byte[] MyConst2 = "Test\0\\\r\n\t\""u8.ToArray(); + + [NativeTypeName("const char *const")] + public static ReadOnlySpan MyConst3 => "Test\0\\\r\n\t\""u8; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Compatible.xml new file mode 100644 index 00000000..9a7c592b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Compatible.xml @@ -0,0 +1,25 @@ + + + + + + ReadOnlySpan<byte> + + new byte[] { 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 } + + + + byte[] + + new byte[] { 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 } + + + + ReadOnlySpan<byte> + + new byte[] { 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 } + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Default.xml new file mode 100644 index 00000000..d1e476bc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Default.xml @@ -0,0 +1,25 @@ + + + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + byte[] + + "Test\0\\\r\n\t\""u8.ToArray() + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Latest.xml new file mode 100644 index 00000000..d1e476bc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Latest.xml @@ -0,0 +1,25 @@ + + + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + byte[] + + "Test\0\\\r\n\t\""u8.ToArray() + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Preview.xml new file mode 100644 index 00000000..d1e476bc --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/StringLiteralStaticConstTest.Xml.Preview.xml @@ -0,0 +1,25 @@ + + + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + byte[] + + "Test\0\\\r\n\t\""u8.ToArray() + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..720d1850 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,13 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 (long)0x80000000L")] + public static readonly IntPtr MyMacro1 = unchecked((nint)(0x80000000)); + + [NativeTypeName("#define MyMacro2 (int)0x80000000")] + public const int MyMacro2 = unchecked((int)(0x80000000)); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..c3a28b0d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Compatible.Windows.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 (long)0x80000000L")] + public const int MyMacro1 = unchecked((int)(0x80000000)); + + [NativeTypeName("#define MyMacro2 (int)0x80000000")] + public const int MyMacro2 = unchecked((int)(0x80000000)); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..c1042638 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Default.Unix.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 (long)0x80000000L")] + public static readonly nint MyMacro1 = unchecked((nint)(0x80000000)); + + [NativeTypeName("#define MyMacro2 (int)0x80000000")] + public const int MyMacro2 = unchecked((int)(0x80000000)); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Default.Windows.cs new file mode 100644 index 00000000..c3a28b0d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Default.Windows.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 (long)0x80000000L")] + public const int MyMacro1 = unchecked((int)(0x80000000)); + + [NativeTypeName("#define MyMacro2 (int)0x80000000")] + public const int MyMacro2 = unchecked((int)(0x80000000)); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..c1042638 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Latest.Unix.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 (long)0x80000000L")] + public static readonly nint MyMacro1 = unchecked((nint)(0x80000000)); + + [NativeTypeName("#define MyMacro2 (int)0x80000000")] + public const int MyMacro2 = unchecked((int)(0x80000000)); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..c3a28b0d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Latest.Windows.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 (long)0x80000000L")] + public const int MyMacro1 = unchecked((int)(0x80000000)); + + [NativeTypeName("#define MyMacro2 (int)0x80000000")] + public const int MyMacro2 = unchecked((int)(0x80000000)); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..c1042638 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Preview.Unix.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 (long)0x80000000L")] + public static readonly nint MyMacro1 = unchecked((nint)(0x80000000)); + + [NativeTypeName("#define MyMacro2 (int)0x80000000")] + public const int MyMacro2 = unchecked((int)(0x80000000)); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..c3a28b0d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.CSharp.Preview.Windows.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 (long)0x80000000L")] + public const int MyMacro1 = unchecked((int)(0x80000000)); + + [NativeTypeName("#define MyMacro2 (int)0x80000000")] + public const int MyMacro2 = unchecked((int)(0x80000000)); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..0d0ad6da --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Compatible.Unix.xml @@ -0,0 +1,27 @@ + + + + + + IntPtr + + + + (nint)(0x80000000) + + + + + + int + + + + (int)(0x80000000) + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Compatible.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Compatible.Windows.xml new file mode 100644 index 00000000..bf1857dd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Compatible.Windows.xml @@ -0,0 +1,27 @@ + + + + + + int + + + + (int)(0x80000000) + + + + + + int + + + + (int)(0x80000000) + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..ed351b0a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Default.Unix.xml @@ -0,0 +1,27 @@ + + + + + + nint + + + + (nint)(0x80000000) + + + + + + int + + + + (int)(0x80000000) + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Default.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Default.Windows.xml new file mode 100644 index 00000000..bf1857dd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Default.Windows.xml @@ -0,0 +1,27 @@ + + + + + + int + + + + (int)(0x80000000) + + + + + + int + + + + (int)(0x80000000) + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..ed351b0a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Latest.Unix.xml @@ -0,0 +1,27 @@ + + + + + + nint + + + + (nint)(0x80000000) + + + + + + int + + + + (int)(0x80000000) + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Latest.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Latest.Windows.xml new file mode 100644 index 00000000..bf1857dd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Latest.Windows.xml @@ -0,0 +1,27 @@ + + + + + + int + + + + (int)(0x80000000) + + + + + + int + + + + (int)(0x80000000) + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..ed351b0a --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Preview.Unix.xml @@ -0,0 +1,27 @@ + + + + + + nint + + + + (nint)(0x80000000) + + + + + + int + + + + (int)(0x80000000) + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Preview.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Preview.Windows.xml new file mode 100644 index 00000000..bf1857dd --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest.Xml.Preview.Windows.xml @@ -0,0 +1,27 @@ + + + + + + int + + + + (int)(0x80000000) + + + + + + int + + + + (int)(0x80000000) + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..faf08d85 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Compatible.Unix.cs @@ -0,0 +1,10 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro3 MyMacro2(3)")] + public const int MyMacro3 = unchecked((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..4ad3a2d9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Compatible.Windows.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro3 MyMacro2(3)")] + public const int MyMacro3 = unchecked((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Default.Unix.cs new file mode 100644 index 00000000..d655519d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Default.Unix.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro3 MyMacro2(3)")] + public const int MyMacro3 = unchecked((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Default.Windows.cs new file mode 100644 index 00000000..4ad3a2d9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Default.Windows.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro3 MyMacro2(3)")] + public const int MyMacro3 = unchecked((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..d655519d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Latest.Unix.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro3 MyMacro2(3)")] + public const int MyMacro3 = unchecked((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..4ad3a2d9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Latest.Windows.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro3 MyMacro2(3)")] + public const int MyMacro3 = unchecked((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..d655519d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Preview.Unix.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro3 MyMacro2(3)")] + public const int MyMacro3 = unchecked((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..4ad3a2d9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.CSharp.Preview.Windows.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro3 MyMacro2(3)")] + public const int MyMacro3 = unchecked((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..1cb561a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Compatible.Unix.xml @@ -0,0 +1,15 @@ + + + + + + int + + + ((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))) + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Compatible.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Compatible.Windows.xml new file mode 100644 index 00000000..be3b578b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Compatible.Windows.xml @@ -0,0 +1,15 @@ + + + + + + int + + + ((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))) + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Default.Unix.xml new file mode 100644 index 00000000..1cb561a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Default.Unix.xml @@ -0,0 +1,15 @@ + + + + + + int + + + ((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))) + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Default.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Default.Windows.xml new file mode 100644 index 00000000..be3b578b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Default.Windows.xml @@ -0,0 +1,15 @@ + + + + + + int + + + ((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))) + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Latest.Unix.xml new file mode 100644 index 00000000..1cb561a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Latest.Unix.xml @@ -0,0 +1,15 @@ + + + + + + int + + + ((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))) + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Latest.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Latest.Windows.xml new file mode 100644 index 00000000..be3b578b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Latest.Windows.xml @@ -0,0 +1,15 @@ + + + + + + int + + + ((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))) + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Preview.Unix.xml new file mode 100644 index 00000000..1cb561a7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Preview.Unix.xml @@ -0,0 +1,15 @@ + + + + + + int + + + ((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))) + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Preview.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Preview.Windows.xml new file mode 100644 index 00000000..be3b578b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedConversionMacroTest2.Xml.Preview.Windows.xml @@ -0,0 +1,15 @@ + + + + + + int + + + ((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))) + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedFunctionLikeCastMacroTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedFunctionLikeCastMacroTest.CSharp.cs new file mode 100644 index 00000000..162e9544 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedFunctionLikeCastMacroTest.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 unsigned(-1)")] + public const uint MyMacro1 = unchecked((uint)(-1)); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedFunctionLikeCastMacroTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedFunctionLikeCastMacroTest.Xml.xml new file mode 100644 index 00000000..7d122724 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedFunctionLikeCastMacroTest.Xml.xml @@ -0,0 +1,17 @@ + + + + + + uint + + + + (uint)(-1) + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedPointerMacroTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedPointerMacroTest.CSharp.cs new file mode 100644 index 00000000..b8bdbc94 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedPointerMacroTest.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + [NativeTypeName("#define Macro1 ((int*) -1)")] + public static readonly int* Macro1 = unchecked((int*)(-1)); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedPointerMacroTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedPointerMacroTest.Xml.xml new file mode 100644 index 00000000..49c946e5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedPointerMacroTest.Xml.xml @@ -0,0 +1,15 @@ + + + + + + int* + + + ((int*)(-1)) + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedReinterpretCastMacroTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedReinterpretCastMacroTest.CSharp.cs new file mode 100644 index 00000000..fd4744a9 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedReinterpretCastMacroTest.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + [NativeTypeName("#define Macro1 reinterpret_cast(-1)")] + public static readonly int* Macro1 = unchecked((int*)(-1)); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedReinterpretCastMacroTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedReinterpretCastMacroTest.Xml.xml new file mode 100644 index 00000000..ea4bbf5e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UncheckedReinterpretCastMacroTest.Xml.xml @@ -0,0 +1,17 @@ + + + + + + int* + + + + (int*)(-1) + + + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UndefinedFunctionLikeMacroTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UndefinedFunctionLikeMacroTest.CSharp.cs new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UndefinedFunctionLikeMacroTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/UndefinedFunctionLikeMacroTest.Xml.xml new file mode 100644 index 00000000..e69de29b diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf16StringLiteralMacroTest.CSharp.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf16StringLiteralMacroTest.CSharp.cs new file mode 100644 index 00000000..3ada1f94 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf16StringLiteralMacroTest.CSharp.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 u\"Test\0\\\r\n\t\"\"")] + public const string MyMacro1 = "Test\0\\\r\n\t\""; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf16StringLiteralMacroTest.Xml.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf16StringLiteralMacroTest.Xml.xml new file mode 100644 index 00000000..65bd8d43 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf16StringLiteralMacroTest.Xml.xml @@ -0,0 +1,13 @@ + + + + + + string + + "Test\0\\\r\n\t\"" + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Compatible.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Compatible.cs new file mode 100644 index 00000000..27335180 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Compatible.cs @@ -0,0 +1,10 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 \"Test\0\\\r\n\t\"\"")] + public static ReadOnlySpan MyMacro1 => new byte[] { 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Default.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Default.cs new file mode 100644 index 00000000..13809a18 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Default.cs @@ -0,0 +1,10 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 \"Test\0\\\r\n\t\"\"")] + public static ReadOnlySpan MyMacro1 => "Test\0\\\r\n\t\""u8; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Latest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Latest.cs new file mode 100644 index 00000000..13809a18 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Latest.cs @@ -0,0 +1,10 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 \"Test\0\\\r\n\t\"\"")] + public static ReadOnlySpan MyMacro1 => "Test\0\\\r\n\t\""u8; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Preview.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Preview.cs new file mode 100644 index 00000000..13809a18 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.CSharp.Preview.cs @@ -0,0 +1,10 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 \"Test\0\\\r\n\t\"\"")] + public static ReadOnlySpan MyMacro1 => "Test\0\\\r\n\t\""u8; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Compatible.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Compatible.xml new file mode 100644 index 00000000..2598c763 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Compatible.xml @@ -0,0 +1,13 @@ + + + + + + ReadOnlySpan<byte> + + new byte[] { 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 } + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Default.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Default.xml new file mode 100644 index 00000000..98a62320 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Default.xml @@ -0,0 +1,13 @@ + + + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Latest.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Latest.xml new file mode 100644 index 00000000..98a62320 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Latest.xml @@ -0,0 +1,13 @@ + + + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Preview.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Preview.xml new file mode 100644 index 00000000..98a62320 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/Utf8StringLiteralMacroTest.Xml.Preview.xml @@ -0,0 +1,13 @@ + + + + + + ReadOnlySpan<byte> + + "Test\0\\\r\n\t\""u8 + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..c9efd19d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public static readonly uint[] MyConst1 = new uint[] { 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }; + + [NativeTypeName("const wchar_t *")] + public static uint[] MyConst2 = new uint[] { 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }; + + [NativeTypeName("const wchar_t *const")] + public static readonly uint[] MyConst3 = new uint[] { 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..41a1d254 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Compatible.Windows.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public const string MyConst1 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *")] + public static string MyConst2 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *const")] + public const string MyConst3 = "Test\0\\\r\n\t\""; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..0129b46e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Default.Unix.cs @@ -0,0 +1,16 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + + [NativeTypeName("const wchar_t *")] + public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + + [NativeTypeName("const wchar_t *const")] + public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Default.Windows.cs new file mode 100644 index 00000000..41a1d254 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Default.Windows.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public const string MyConst1 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *")] + public static string MyConst2 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *const")] + public const string MyConst3 = "Test\0\\\r\n\t\""; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..0129b46e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Latest.Unix.cs @@ -0,0 +1,16 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + + [NativeTypeName("const wchar_t *")] + public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + + [NativeTypeName("const wchar_t *const")] + public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..41a1d254 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Latest.Windows.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public const string MyConst1 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *")] + public static string MyConst2 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *const")] + public const string MyConst3 = "Test\0\\\r\n\t\""; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..0129b46e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Preview.Unix.cs @@ -0,0 +1,16 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + + [NativeTypeName("const wchar_t *")] + public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + + [NativeTypeName("const wchar_t *const")] + public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..41a1d254 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.CSharp.Preview.Windows.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public const string MyConst1 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *")] + public static string MyConst2 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *const")] + public const string MyConst3 = "Test\0\\\r\n\t\""; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..ef96be99 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Compatible.Unix.xml @@ -0,0 +1,25 @@ + + + + + + uint[] + + new uint[] { 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 } + + + + uint[] + + new uint[] { 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 } + + + + uint[] + + new uint[] { 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 } + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Compatible.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Compatible.Windows.xml new file mode 100644 index 00000000..c0f140cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Compatible.Windows.xml @@ -0,0 +1,25 @@ + + + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..d2d2b53e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Default.Unix.xml @@ -0,0 +1,25 @@ + + + + + + ReadOnlySpan<uint> + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + uint[] + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + ReadOnlySpan<uint> + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Default.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Default.Windows.xml new file mode 100644 index 00000000..c0f140cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Default.Windows.xml @@ -0,0 +1,25 @@ + + + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..d2d2b53e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Latest.Unix.xml @@ -0,0 +1,25 @@ + + + + + + ReadOnlySpan<uint> + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + uint[] + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + ReadOnlySpan<uint> + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Latest.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Latest.Windows.xml new file mode 100644 index 00000000..c0f140cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Latest.Windows.xml @@ -0,0 +1,25 @@ + + + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..d2d2b53e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Preview.Unix.xml @@ -0,0 +1,25 @@ + + + + + + ReadOnlySpan<uint> + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + uint[] + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + ReadOnlySpan<uint> + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Preview.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Preview.Windows.xml new file mode 100644 index 00000000..c0f140cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralConstTest.Xml.Preview.Windows.xml @@ -0,0 +1,25 @@ + + + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..c9efd19d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Compatible.Unix.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public static readonly uint[] MyConst1 = new uint[] { 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }; + + [NativeTypeName("const wchar_t *")] + public static uint[] MyConst2 = new uint[] { 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }; + + [NativeTypeName("const wchar_t *const")] + public static readonly uint[] MyConst3 = new uint[] { 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..41a1d254 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Compatible.Windows.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public const string MyConst1 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *")] + public static string MyConst2 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *const")] + public const string MyConst3 = "Test\0\\\r\n\t\""; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Default.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Default.Unix.cs new file mode 100644 index 00000000..0129b46e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Default.Unix.cs @@ -0,0 +1,16 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + + [NativeTypeName("const wchar_t *")] + public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + + [NativeTypeName("const wchar_t *const")] + public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Default.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Default.Windows.cs new file mode 100644 index 00000000..41a1d254 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Default.Windows.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public const string MyConst1 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *")] + public static string MyConst2 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *const")] + public const string MyConst3 = "Test\0\\\r\n\t\""; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..0129b46e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Latest.Unix.cs @@ -0,0 +1,16 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + + [NativeTypeName("const wchar_t *")] + public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + + [NativeTypeName("const wchar_t *const")] + public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..41a1d254 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Latest.Windows.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public const string MyConst1 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *")] + public static string MyConst2 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *const")] + public const string MyConst3 = "Test\0\\\r\n\t\""; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Preview.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Preview.Unix.cs new file mode 100644 index 00000000..0129b46e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Preview.Unix.cs @@ -0,0 +1,16 @@ +using System; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + + [NativeTypeName("const wchar_t *")] + public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + + [NativeTypeName("const wchar_t *const")] + public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Preview.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Preview.Windows.cs new file mode 100644 index 00000000..41a1d254 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.CSharp.Preview.Windows.cs @@ -0,0 +1,14 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const wchar_t[11]")] + public const string MyConst1 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *")] + public static string MyConst2 = "Test\0\\\r\n\t\""; + + [NativeTypeName("const wchar_t *const")] + public const string MyConst3 = "Test\0\\\r\n\t\""; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Compatible.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Compatible.Unix.xml new file mode 100644 index 00000000..ef96be99 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Compatible.Unix.xml @@ -0,0 +1,25 @@ + + + + + + uint[] + + new uint[] { 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 } + + + + uint[] + + new uint[] { 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 } + + + + uint[] + + new uint[] { 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 } + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Compatible.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Compatible.Windows.xml new file mode 100644 index 00000000..c0f140cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Compatible.Windows.xml @@ -0,0 +1,25 @@ + + + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Default.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Default.Unix.xml new file mode 100644 index 00000000..d2d2b53e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Default.Unix.xml @@ -0,0 +1,25 @@ + + + + + + ReadOnlySpan<uint> + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + uint[] + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + ReadOnlySpan<uint> + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Default.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Default.Windows.xml new file mode 100644 index 00000000..c0f140cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Default.Windows.xml @@ -0,0 +1,25 @@ + + + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Latest.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Latest.Unix.xml new file mode 100644 index 00000000..d2d2b53e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Latest.Unix.xml @@ -0,0 +1,25 @@ + + + + + + ReadOnlySpan<uint> + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + uint[] + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + ReadOnlySpan<uint> + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Latest.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Latest.Windows.xml new file mode 100644 index 00000000..c0f140cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Latest.Windows.xml @@ -0,0 +1,25 @@ + + + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Preview.Unix.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Preview.Unix.xml new file mode 100644 index 00000000..d2d2b53e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Preview.Unix.xml @@ -0,0 +1,25 @@ + + + + + + ReadOnlySpan<uint> + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + uint[] + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + ReadOnlySpan<uint> + + [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Preview.Windows.xml b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Preview.Windows.xml new file mode 100644 index 00000000..c0f140cb --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/VarDeclaration/WideStringLiteralStaticConstTest.Xml.Preview.Windows.xml @@ -0,0 +1,25 @@ + + + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + string + + "Test\0\\\r\n\t\"" + + + + + diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/CXXMethodDeclarationTest.cs new file mode 100644 index 00000000..4a0c9d27 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/CXXMethodDeclarationTest.cs @@ -0,0 +1,360 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System.Threading.Tasks; +using NUnit.Framework; + +namespace ClangSharp.UnitTests.Baseline; + +[TestFixtureSource(nameof(Variants))] +public sealed class CXXMethodDeclarationTest : BaselineTest +{ + public CXXMethodDeclarationTest(BaselineVariant variant) : base(variant) + { + } + + protected override string Area => "CXXMethodDeclaration"; + + [Test] + public Task ConstructorTest() + => ValidateAsync(nameof(ConstructorTest), @"struct MyStruct +{ + int _value; + + MyStruct(int value) + { + _value = value; + } +}; +"); + + [Test] + public Task ConstructorWithInitializeTest() + => ValidateAsync(nameof(ConstructorWithInitializeTest), @"struct MyStruct +{ + int _x; + int _y; + int _z; + + MyStruct(int x) : _x(x) + { + } + + MyStruct(int x, int y) : _x(x), _y(y) + { + } + + MyStruct(int x, int y, int z) : _x(x), _y(y), _z() + { + } +}; +"); + + [Test] + public Task ConversionTest() + => ValidateAsync(nameof(ConversionTest), @"struct MyStruct +{ + int value; + int* pointer; + int** pointer2; + int*** pointer3; + operator int() + { + return value; + } + operator int*() + { + return pointer; + } + operator int**() + { + return pointer2; + } + operator int***() + { + return pointer3; + } +}; +"); + + [Test] + public Task DefaultParameterInheritedFromTemplateTest() + => ValidateAsync(nameof(DefaultParameterInheritedFromTemplateTest), @"template +struct MyTemplate +{ + int* DoWork(int* value = nullptr) + { + return value; + } +}; + +struct MyStruct : public MyTemplate +{}; +"); + + [Test] + public Task DestructorTest() + => ValidateAsync(nameof(DestructorTest), @"struct MyStruct +{ + ~MyStruct() + { + } +}; +"); + + [Test] + public Task InstanceTest() + => ValidateAsync(nameof(InstanceTest), @"struct MyStruct +{ + void MyVoidMethod(); + + int MyInt32Method() + { + return 0; + } + + void* MyVoidStarMethod() + { + return nullptr; + } +}; +"); + + [Test] + public Task MacrosExpansionTest() + => ValidateAsync(nameof(MacrosExpansionTest), @"typedef struct +{ + unsigned char *buf; + int size; +} context_t; + +int buf_close(void *pContext) +{ + ((context_t*)pContext)->buf=0; + return 0; +} +"); + + [Test] + public Task MemberCallTest() + => ValidateAsync(nameof(MemberCallTest), @"struct MyStruct +{ + int value; + + int MyFunction1() + { + return value; + } + + int MyFunction2() + { + return MyFunction1(); + } + + int MyFunction3() + { + return this->MyFunction1(); + } +}; + +int MyFunctionA(MyStruct x) +{ + return x.MyFunction1(); +} + +int MyFunctionB(MyStruct* x) +{ + return x->MyFunction2(); +} +"); + + [Test] + public Task MemberTest() + => ValidateAsync(nameof(MemberTest), @"struct MyStruct +{ + int value; + + int MyFunction() + { + return value; + } +}; +"); + + [Test] + public Task NewKeywordTest() + => ValidateAsync(nameof(NewKeywordTest), @"struct MyStruct +{ + int Equals() { return 0; } + int Equals(int obj) { return 0; } + int Dispose() { return 0; } + int Dispose(int obj) { return 0; } + int GetHashCode() { return 0; } + int GetHashCode(int obj) { return 0; } + int GetType() { return 0; } + int GetType(int obj) { return 0; } + int MemberwiseClone() { return 0; } + int MemberwiseClone(int obj) { return 0; } + int ReferenceEquals() { return 0; } + int ReferenceEquals(int obj) { return 0; } + int ToString() { return 0; } + int ToString(int obj) { return 0; } +};"); + + [Test] + public Task NewKeywordVirtualTest() + => ValidateAsync(nameof(NewKeywordVirtualTest), @"struct MyStruct +{ + virtual int GetType(int obj) = 0; + virtual int GetType() = 0; + virtual int GetType(int objA, int objB) = 0; +};"); + + [Test] + public Task NewKeywordVirtualWithExplicitVtblTest() + => ValidateAsync(nameof(NewKeywordVirtualWithExplicitVtblTest), @"struct MyStruct +{ + virtual int GetType(int obj) = 0; + virtual int GetType() = 0; + virtual int GetType(int objA, int objB) = 0; +};", additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + + [Test] + public Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest() + => ValidateAsync(nameof(NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTest), @"struct MyStruct +{ + virtual int GetType(int obj) = 0; + virtual int GetType() = 0; + virtual int GetType(int objA, int objB) = 0; +};", additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + + [Test] + public Task OperatorTest() + => ValidateAsync(nameof(OperatorTest), @"struct MyStruct +{ + int value; + + MyStruct(int value) : value(value) + { + } + + MyStruct operator+(MyStruct rhs) + { + return MyStruct(value + rhs.value); + } +}; + +MyStruct operator-(MyStruct lhs, MyStruct rhs) +{ + return MyStruct(lhs.value - rhs.value); +} +"); + + [Test] + public Task OperatorCallTest() + => ValidateAsync(nameof(OperatorCallTest), @"struct MyStruct +{ + int value; + + MyStruct(int value) : value(value) + { + } + + MyStruct operator+(MyStruct rhs) + { + return MyStruct(value + rhs.value); + } +}; + +MyStruct MyFunction1(MyStruct lhs, MyStruct rhs) +{ + return lhs + rhs; +} + +MyStruct operator-(MyStruct lhs, MyStruct rhs) +{ + return MyStruct(lhs.value - rhs.value); +} + +MyStruct MyFunction2(MyStruct lhs, MyStruct rhs) +{ + return lhs - rhs; +} +"); + + [Test] + public Task StaticTest() + => ValidateAsync(nameof(StaticTest), @"struct MyStruct +{ + static void MyVoidMethod(); + + static int MyInt32Method() + { + return 0; + } + + static void* MyVoidStarMethod() + { + return nullptr; + } +}; +"); + + [Test] + public Task ThisTest() + => ValidateAsync(nameof(ThisTest), @"struct MyStruct +{ + int value; + + int MyFunction() + { + return this->value; + } +}; +"); + + [Test] + public Task UnsafeDoesNotImpactDllImportTest() + => ValidateAsync(nameof(UnsafeDoesNotImpactDllImportTest), @"struct MyStruct +{ + void* MyVoidStarMethod() + { + return nullptr; + } +}; + +extern ""C"" void MyFunction();"); + + [Test] + public Task VirtualTest() + => ValidateAsync(nameof(VirtualTest), @"struct MyStruct +{ + virtual void MyVoidMethod() = 0; + + virtual signed char MyInt8Method() + { + return 0; + } + + virtual int MyInt32Method(); + + virtual void* MyVoidStarMethod() = 0; +}; +"); + + [Test] + public Task VirtualWithVtblIndexAttributeTest() + => ValidateAsync(nameof(VirtualWithVtblIndexAttributeTest), @"struct MyStruct +{ + virtual void MyVoidMethod() = 0; + + virtual signed char MyInt8Method() + { + return 0; + } + + virtual int MyInt32Method(); + + virtual void* MyVoidStarMethod() = 0; +}; +", additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/DeprecatedToObsoleteTest.cs new file mode 100644 index 00000000..bd925385 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/DeprecatedToObsoleteTest.cs @@ -0,0 +1,253 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System.Threading.Tasks; +using NUnit.Framework; + +namespace ClangSharp.UnitTests.Baseline; + +[TestFixtureSource(nameof(Variants))] +public sealed class DeprecatedToObsoleteTest : BaselineTest +{ + public DeprecatedToObsoleteTest(BaselineVariant variant) : base(variant) + { + } + + protected override string Area => "DeprecatedToObsolete"; + + [TestCase("int", "int")] + public Task SimpleStructMembers(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct +{{ + {nativeType} r; + + [[deprecated]] + {nativeType} g; + + [[deprecated(""This is obsolete."")]] + {nativeType} b; + + {nativeType} a; +}}; +"; + + return ValidateAsync(nameof(SimpleStructMembers), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [Test] + public Task StructDecl() + { + var inputContents = $@"struct MyStruct0 +{{ + int r; +}}; + +struct [[deprecated]] MyStruct1 +{{ + int r; +}}; + +struct [[deprecated(""This is obsolete."")]] MyStruct2 +{{ + int r; +}}; + +struct MyStruct3 +{{ + int r; +}}; +"; + + return ValidateAsync(nameof(StructDecl), inputContents); + } + + [TestCase("int", "int")] + public Task SimpleTypedefStructMembers(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct +{{ + {nativeType} r; + + [[deprecated]] + {nativeType} g; + + [[deprecated(""This is obsolete."")]] + {nativeType} b; + + {nativeType} a; +}} MyStruct; +"; + + return ValidateAsync(nameof(SimpleTypedefStructMembers), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [Test] + public Task TypedefStructDecl() + { + var inputContents = $@"typedef struct +{{ + int r; +}} MyStruct0; + +[[deprecated]] typedef struct +{{ + int r; +}} MyStruct1; + +[[deprecated(""This is obsolete."")]] typedef struct +{{ + int r; +}} MyStruct2; + +typedef struct +{{ + int r; +}} MyStruct3; +"; + + return ValidateAsync(nameof(TypedefStructDecl), inputContents); + } + + [Test] + public Task SimpleEnumMembers() + { + var inputContents = $@"enum MyEnum : int +{{ + MyEnum_Value0, + MyEnum_Value1 [[deprecated]], + MyEnum_Value2 [[deprecated(""This is obsolete."")]], + MyEnum_Value3, +}}; +"; + + return ValidateAsync(nameof(SimpleEnumMembers), inputContents); + } + + [Test] + public Task EnumDecl() + { + var inputContents = $@"enum MyEnum0 : int +{{ + MyEnum_Value0, +}}; + +enum [[deprecated]] MyEnum1 : int +{{ + MyEnum_Value1, +}}; + +enum [[deprecated(""This is obsolete."")]] MyEnum2 : int +{{ + MyEnum_Value2, +}}; + + +enum MyEnum3 : int +{{ + MyEnum_Value3, +}}; +"; + + return ValidateAsync(nameof(EnumDecl), inputContents); + } + + [TestCase("int", "int")] + public Task SimpleVarDecl(string nativeType, string expectedManagedType) + { + var inputContents = $@" +{nativeType} MyVariable0 = 0; + +[[deprecated]] +{nativeType} MyVariable1 = 0; + +[[deprecated(""This is obsolete."")]] +{nativeType} MyVariable2 = 0; + +{nativeType} MyVariable3 = 0;"; + + return ValidateAsync(nameof(SimpleVarDecl), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [Test] + public Task FuncDecl() + { + var inputContents = @" +void MyFunction0() +{ +} + +[[deprecated]] +void MyFunction1() +{ +} + +[[deprecated(""This is obsolete."")]] +void MyFunction2() +{ +} + +void MyFunction3() +{ +} +"; + + return ValidateAsync(nameof(FuncDecl), inputContents); + } + + [Test] + public Task InstanceFunc() + { + var inputContents = @"struct MyStruct +{ + int MyFunction0() { return 0; } + + [[deprecated]] + int MyFunction1() { return 0; } + + [[deprecated(""This is obsolete."")]] + int MyFunction2() { return 0; } + + int MyFunction3() { return 0; } +};"; + + return ValidateAsync(nameof(InstanceFunc), inputContents); + } + + [Test] + public Task FuncPtrDecl() + { + var inputContents = @" +typedef void (*Callback0)(); +[[deprecated]] typedef void (*Callback1)(); +[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); +typedef void (*Callback3)(); + +struct MyStruct0 { + Callback0 _callback; +}; +struct MyStruct1 { + Callback1 _callback; +}; +struct MyStruct2 { + Callback2 _callback; +}; +struct MyStruct3 { + Callback3 _callback; +}; +"; + + return ValidateAsync(nameof(FuncPtrDecl), inputContents); + } + + [Test] + public Task FuncDeclDllImport() + { + var inputContents = @" +extern ""C"" void MyFunction0(); +extern ""C"" [[deprecated]] void MyFunction1(); +extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); +extern ""C"" void MyFunction3();"; + + return ValidateAsync(nameof(FuncDeclDllImport), inputContents); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/DigitsSeparatorTest.cs new file mode 100644 index 00000000..500f8b43 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/DigitsSeparatorTest.cs @@ -0,0 +1,37 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System.Threading.Tasks; +using NUnit.Framework; + +namespace ClangSharp.UnitTests.Baseline; + +// Proof-of-concept: DigitsSeparatorTest migrated to the baseline model. A second area demonstrating the +// harness generalizes across the repo's two divergent fixture-naming conventions (this area is +// namespace-scoped, VarDeclaration is name-prefixed) and multi-argument TestCases whose first argument is +// not a unique discriminator. +[TestFixtureSource(nameof(Variants))] +public sealed class DigitsSeparatorTest : BaselineTest +{ + public DigitsSeparatorTest(BaselineVariant variant) : base(variant) + { + } + + protected override string Area => "DigitsSeparator"; + + [TestCase("int", "1'024", "1_024")] + [TestCase("int", "1'000'001", "1_000_001")] + [TestCase("float", "1'024", "1_024")] + [TestCase("float", "1'024.0", "1_024.0")] + public Task StaticConstExprTest(string type, string nativeValue, string expectedValue) + { + var inputContents = $@"class MyClass +{{ + private: + + static constexpr {type} x = {nativeValue}; +}}; +"; + + return ValidateAsync(nameof(StaticConstExprTest), inputContents, discriminator: $"{type}_{nativeValue}_{expectedValue}"); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/EnumDeclarationTest.cs new file mode 100644 index 00000000..2ec592a8 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/EnumDeclarationTest.cs @@ -0,0 +1,345 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System.Collections.Generic; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace ClangSharp.UnitTests.Baseline; + +[TestFixtureSource(nameof(Variants))] +public sealed class EnumDeclarationTest : BaselineTest +{ + private static readonly string[] ExcludeTestExcludedNames = ["MyEnum"]; + + public EnumDeclarationTest(BaselineVariant variant) : base(variant) + { + } + + protected override string Area => "EnumDeclaration"; + + [Test] + public Task BasicTest() + => ValidateAsync(nameof(BasicTest), @"enum MyEnum : int +{ + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, +}; +"); + + [Test] + public Task BasicValueTest() + => ValidateAsync(nameof(BasicValueTest), @"enum MyEnum : int +{ + MyEnum_Value1 = 1, + MyEnum_Value2, + MyEnum_Value3, +}; +"); + + [Test] + public Task ExcludeTest() + => ValidateAsync(nameof(ExcludeTest), @"enum MyEnum : int +{ + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, +}; +", excludedNames: ExcludeTestExcludedNames); + + [TestCase("short", "short")] + public Task ExplicitTypedTest(string nativeType, string expectedManagedType) + => ValidateAsync(nameof(ExplicitTypedTest), $@"enum MyEnum : {nativeType} +{{ + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, +}}; +", discriminator: $"{nativeType}_{expectedManagedType}"); + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + public Task ExplicitTypedWithNativeTypeNameTest(string nativeType, string expectedManagedType) + => ValidateAsync(nameof(ExplicitTypedWithNativeTypeNameTest), $@"enum MyEnum : {nativeType} +{{ + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, +}}; +", discriminator: $"{nativeType}_{expectedManagedType}"); + + [Test] + public Task RemapTest() + { + var inputContents = @"typedef enum _MyEnum1 : int +{ + MyEnum1_Value1, + MyEnum1_Value2, + MyEnum1_Value3, +} MyEnum1; + +namespace Namespace1 +{ + namespace Namespace2 + { + typedef enum _MyEnum2 : int + { + MyEnum2_Value1, + MyEnum2_Value2, + MyEnum2_Value3, + } MyEnum2; + + typedef enum _MyEnum3 : int + { + MyEnum3_Value1, + MyEnum3_Value2, + MyEnum3_Value3, + } MyEnum3; + + typedef enum _MyEnum4 : int + { + MyEnum4_Value1, + MyEnum4_Value2, + MyEnum4_Value3, + } MyEnum4; + } +} +"; + + var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; + return ValidateAsync(nameof(RemapTest), inputContents, remappedNames: remappedNames); + } + + [Test] + public Task WithAttributeTest() + { + var inputContents = @"enum MyEnum1 : int +{ + MyEnum1_Value1 = 1, +}; + +enum MyEnum2 : int +{ + MyEnum2_Value1 = 1, +}; +"; + + var withAttributes = new Dictionary> + { + ["MyEnum1"] = ["Flags"] + }; + return ValidateAsync(nameof(WithAttributeTest), inputContents, withAttributes: withAttributes); + } + + [Test] + public Task WithNamespaceTest() + { + var inputContents = @"enum MyEnum1 : int +{ + MyEnum1_Value1 = 1, +}; + +enum MyEnum2 : int +{ + MyEnum2_Value1 = MyEnum1_Value1, +}; +"; + + var withNamespaces = new Dictionary> + { + ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] + }; + return ValidateAsync(nameof(WithNamespaceTest), inputContents, withUsings: withNamespaces); + } + + [Test] + public Task WithNamespaceStarTest() + { + var inputContents = @"enum MyEnum1 : int +{ + MyEnum1_Value1 = 1, +}; + +enum MyEnum2 : int +{ + MyEnum2_Value1 = MyEnum1_Value1, +}; +"; + + var withNamespaces = new Dictionary> + { + ["*"] = ["static ClangSharp.Test.MyEnum1"] + }; + return ValidateAsync(nameof(WithNamespaceStarTest), inputContents, withUsings: withNamespaces); + } + + [Test] + public Task WithNamespaceStarPlusTest() + { + var inputContents = @"enum MyEnum1 : int +{ + MyEnum1_Value1 = 1, +}; + +enum MyEnum2 : int +{ + MyEnum2_Value1 = MyEnum1_Value1, +}; +"; + + var withNamespaces = new Dictionary> + { + ["*"] = ["static ClangSharp.Test.MyEnum1"], + ["MyEnum2"] = ["System"] + }; + return ValidateAsync(nameof(WithNamespaceStarPlusTest), inputContents, withUsings: withNamespaces); + } + + [Test] + public Task WithCastToEnumType() + => ValidateAsync(nameof(WithCastToEnumType), @"enum MyEnum : int +{ + MyEnum_Value0 = (MyEnum) 10, + MyEnum_Value1 = (MyEnum) MyEnum_Value0, + MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, +}; +"); + + [Test] + public Task WithMultipleEnumsTest() + => ValidateAsync(nameof(WithMultipleEnumsTest), @"enum MyEnum1 : int +{ + MyEnum1_Value0 = 10, +}; + +enum MyEnum2 : int +{ + MyEnum2_Value0 = MyEnum1_Value0, + MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, +}; +"); + + [Test] + public Task WithImplicitConversionTest() + => ValidateAsync(nameof(WithImplicitConversionTest), @"enum MyEnum : int +{ + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2 = 0x80000000, +}; +"); + + [Test] + public Task WithTypeTest() + { + var inputContents = @"enum MyEnum : int +{ + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, +}; +"; + + var withTypes = new Dictionary { + ["MyEnum"] = "uint" + }; + return ValidateAsync(nameof(WithTypeTest), inputContents, withTypes: withTypes); + } + + [Test] + public Task WithTypeAndImplicitConversionTest() + { + var inputContents = @"enum MyEnum : int +{ + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2 = 0x80000000, +}; +"; + + var withTypes = new Dictionary + { + ["MyEnum"] = "uint" + }; + return ValidateAsync(nameof(WithTypeAndImplicitConversionTest), inputContents, withTypes: withTypes); + } + + [Test] + public Task WithTypeStarTest() + { + var inputContents = @"enum MyEnum1 : int +{ + MyEnum1_Value0 +}; + +enum MyEnum2 : int +{ + MyEnum2_Value0 +}; +"; + + var withTypes = new Dictionary + { + ["*"] = "uint" + }; + return ValidateAsync(nameof(WithTypeStarTest), inputContents, withTypes: withTypes); + } + + [Test] + public Task WithTypeStarOverrideTest() + { + var inputContents = @"enum MyEnum1 : int +{ + MyEnum1_Value0 +}; + +enum MyEnum2 : int +{ + MyEnum2_Value0 +}; +"; + + var withTypes = new Dictionary + { + ["*"] = "uint", + ["MyEnum1"] = "int", + }; + return ValidateAsync(nameof(WithTypeStarOverrideTest), inputContents, withTypes: withTypes); + } + + [Test] + public Task WithAnonymousEnumTest() + { + var inputContents = @"enum +{ + MyEnum1_Value1 = 1, +}; + +enum MyEnum2 : int +{ + MyEnum2_Value1 = MyEnum1_Value1, +}; +"; + + var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; + return ValidateAsync(nameof(WithAnonymousEnumTest), inputContents, expectedDiagnostics: diagnostics); + } + + [Test] + public Task WithReferenceToAnonymousEnumEnumeratorTest() + { + var inputContents = @"enum +{ + MyEnum1_Value1 = 1, +}; + +const int MyEnum2_Value1 = MyEnum1_Value1 + 1; +"; + var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; + return ValidateAsync(nameof(WithReferenceToAnonymousEnumEnumeratorTest), inputContents, expectedDiagnostics: diagnostics); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/FunctionDeclarationBodyImportTest.cs new file mode 100644 index 00000000..b9e29c10 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/FunctionDeclarationBodyImportTest.cs @@ -0,0 +1,913 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System.Threading.Tasks; +using NUnit.Framework; + +namespace ClangSharp.UnitTests.Baseline; + +[TestFixtureSource(nameof(Variants))] +public sealed class FunctionDeclarationBodyImportTest : BaselineTest +{ + public FunctionDeclarationBodyImportTest(BaselineVariant variant) : base(variant) + { + } + + protected override string Area => "FunctionDeclarationBodyImport"; + + [Test] + public Task AccessUnionMemberTest() + { + var inputContents = @"union MyUnion +{ + struct { int a; }; +}; + +void MyFunction() +{ + MyUnion myUnion; + myUnion.a = 10; +} +"; + + return ValidateAsync(nameof(AccessUnionMemberTest), inputContents); + } + + [Test] + public Task ArraySubscriptTest() + { + var inputContents = @"int MyFunction(int* pData, int index) +{ + return pData[index]; +} +"; + + return ValidateAsync(nameof(ArraySubscriptTest), inputContents); + } + + [Test] + public Task BasicTest() + { + var inputContents = @"void MyFunction() +{ +} +"; + + return ValidateAsync(nameof(BasicTest), inputContents); + } + + [TestCase("%")] + [TestCase("%=")] + [TestCase("&")] + [TestCase("&=")] + [TestCase("*")] + [TestCase("*=")] + [TestCase("+")] + [TestCase("+=")] + [TestCase("-")] + [TestCase("-=")] + [TestCase("/")] + [TestCase("/=")] + [TestCase("<<")] + [TestCase("<<=")] + [TestCase("=")] + [TestCase(">>")] + [TestCase(">>=")] + [TestCase("^")] + [TestCase("^=")] + [TestCase("|")] + [TestCase("|=")] + public Task BinaryOperatorBasicTest(string opcode) + { + var inputContents = $@"int MyFunction(int x, int y) +{{ + return x {opcode} y; +}} +"; + + return ValidateAsync(nameof(BinaryOperatorBasicTest), inputContents, discriminator: $"{opcode}"); + } + + [TestCase("==")] + [TestCase("!=")] + [TestCase("<")] + [TestCase("<=")] + [TestCase(">")] + [TestCase(">=")] + public Task BinaryOperatorCompareTest(string opcode) + { + var inputContents = $@"bool MyFunction(int x, int y) +{{ + return x {opcode} y; +}} +"; + + return ValidateAsync(nameof(BinaryOperatorCompareTest), inputContents, discriminator: $"{opcode}"); + } + + [TestCase("&&")] + [TestCase("||")] + public Task BinaryOperatorBooleanTest(string opcode) + { + var inputContents = $@"bool MyFunction(bool x, bool y) +{{ + return x {opcode} y; +}} +"; + + return ValidateAsync(nameof(BinaryOperatorBooleanTest), inputContents, discriminator: $"{opcode}"); + } + + [Test] + public Task BreakTest() + { + var inputContents = @"int MyFunction(int value) +{ + while (true) + { + break; + } + + return 0; +} +"; + + return ValidateAsync(nameof(BreakTest), inputContents); + } + + [Test] + public Task CallFunctionTest() + { + var inputContents = @"void MyCalledFunction() +{ +} + +void MyFunction() +{ + MyCalledFunction(); +} +"; + + return ValidateAsync(nameof(CallFunctionTest), inputContents); + } + + [Test] + public Task CallFunctionWithArgsTest() + { + var inputContents = @"void MyCalledFunction(int x, int y) +{ +} + +void MyFunction() +{ + MyCalledFunction(0, 1); +} +"; + + return ValidateAsync(nameof(CallFunctionWithArgsTest), inputContents); + } + + [Test] + public Task CaseTest() + { + var inputContents = @"int MyFunction(int value) +{ + switch (value) + { + case 0: + { + return 0; + } + + case 1: + case 2: + { + return 3; + } + } + + return -1; +} +"; + + return ValidateAsync(nameof(CaseTest), inputContents); + } + + [Test] + public Task CaseNoCompoundTest() + { + var inputContents = @"int MyFunction(int value) +{ + switch (value) + { + case 0: + return 0; + + case 2: + case 3: + return 5; + } + + return -1; +} +"; + + return ValidateAsync(nameof(CaseNoCompoundTest), inputContents); + } + + [Test] + public Task CompareMultipleEnumTest() + { + var inputContents = @"enum MyEnum : int +{ + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, +}; + +static inline int MyFunction(MyEnum x) +{ + return x == MyEnum_Value0 || + x == MyEnum_Value1 || + x == MyEnum_Value2; +} +"; + + return ValidateAsync(nameof(CompareMultipleEnumTest), inputContents); + } + + [Test] + public Task ConditionalOperatorTest() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) +{ + return condition ? lhs : rhs; +} +"; + + return ValidateAsync(nameof(ConditionalOperatorTest), inputContents); + } + + [Test] + public Task ContinueTest() + { + var inputContents = @"int MyFunction(int value) +{ + while (true) + { + continue; + } + + return 0; +} +"; + + return ValidateAsync(nameof(ContinueTest), inputContents); + } + + [Test] + public Task CStyleFunctionalCastTest() + { + var inputContents = @"int MyFunction(float input) +{ + return (int)input; +} +"; + + return ValidateAsync(nameof(CStyleFunctionalCastTest), inputContents); + } + + [Test] + public Task CxxFunctionalCastTest() + { + var inputContents = @"int MyFunction(float input) +{ + return int(input); +} +"; + + return ValidateAsync(nameof(CxxFunctionalCastTest), inputContents); + } + + [Test] + public Task CxxConstCastTest() + { + var inputContents = @"void* MyFunction(const void* input) +{ + return const_cast(input); +} +"; + + return ValidateAsync(nameof(CxxConstCastTest), inputContents); + } + + [Test] + public Task CxxDynamicCastTest() + { + var inputContents = @"struct MyStructA +{ + virtual void MyMethod() = 0; +}; + +struct MyStructB : MyStructA { }; + +MyStructB* MyFunction(MyStructA* input) +{ + return dynamic_cast(input); +} +"; + + return ValidateAsync(nameof(CxxDynamicCastTest), inputContents); + } + + [Test] + public Task CxxReinterpretCastTest() + { + var inputContents = @"int* MyFunction(void* input) +{ + return reinterpret_cast(input); +} +"; + + return ValidateAsync(nameof(CxxReinterpretCastTest), inputContents); + } + + [Test] + public Task CxxStaticCastTest() + { + var inputContents = @"int* MyFunction(void* input) +{ + return static_cast(input); +} +"; + + return ValidateAsync(nameof(CxxStaticCastTest), inputContents); + } + + [Test] + public Task DeclTest() + { + var inputContents = @"\ +int MyFunction() +{ + int x = 0; + int y = 1, z = 2; + return x + y + z; +} +"; + + return ValidateAsync(nameof(DeclTest), inputContents); + } + + [Test] + public Task DoTest() + { + var inputContents = @"int MyFunction(int count) +{ + int i = 0; + + do + { + i++; + } + while (i < count); + + return i; +} +"; + + return ValidateAsync(nameof(DoTest), inputContents); + } + + [Test] + public Task DoNonCompoundTest() + { + var inputContents = @"int MyFunction(int count) +{ + int i = 0; + + while (i < count) + i++; + + return i; +} +"; + + return ValidateAsync(nameof(DoNonCompoundTest), inputContents); + } + + [Test] + public Task ForTest() + { + var inputContents = @"int MyFunction(int count) +{ + for (int i = 0; i < count; i--) + { + i += 2; + } + + int x; + + for (x = 0; x < count; x--) + { + x += 2; + } + + x = 0; + + for (; x < count; x--) + { + x += 2; + } + + for (int i = 0;;i--) + { + i += 2; + } + + for (x = 0;;x--) + { + x += 2; + } + + for (int i = 0; i < count;) + { + i++; + } + + for (x = 0; x < count;) + { + x++; + } + + // x = 0; + // + // for (;; x--) + // { + // x += 2; + // } + + x = 0; + + for (; x < count;) + { + x++; + } + + for (int i = 0;;) + { + i++; + } + + for (x = 0;;) + { + x++; + } + + for (;;) + { + return -1; + } +} +"; + + return ValidateAsync(nameof(ForTest), inputContents); + } + + [Test] + public Task ForNonCompoundTest() + { + var inputContents = @"int MyFunction(int count) +{ + for (int i = 0; i < count; i--) + i += 2; + + int x; + + for (x = 0; x < count; x--) + x += 2; + + x = 0; + + for (; x < count; x--) + x += 2; + + for (int i = 0;;i--) + i += 2; + + for (x = 0;;x--) + x += 2; + + for (int i = 0; i < count;) + i++; + + for (x = 0; x < count;) + x++; + + // x = 0; + // + // for (;; x--) + // x += 2; + + x = 0; + + for (; x < count;) + x++; + + for (int i = 0;;) + i++; + + for (x = 0;;) + x++; + + for (;;) + return -1; +} +"; + + return ValidateAsync(nameof(ForNonCompoundTest), inputContents); + } + + [Test] + public Task IfTest() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) +{ + if (condition) + { + return lhs; + } + + return rhs; +} +"; + + return ValidateAsync(nameof(IfTest), inputContents); + } + + [Test] + public Task IfElseTest() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) +{ + if (condition) + { + return lhs; + } + else + { + return rhs; + } +} +"; + + return ValidateAsync(nameof(IfElseTest), inputContents); + } + + [Test] + public Task IfElseIfTest() + { + var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) +{ + if (condition1) + { + return a; + } + else if (condition2) + { + return b; + } + + return c; +} +"; + + return ValidateAsync(nameof(IfElseIfTest), inputContents); + } + + [Test] + public Task IfElseNonCompoundTest() + { + var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) +{ + if (condition) + return lhs; + else + return rhs; +} +"; + + return ValidateAsync(nameof(IfElseNonCompoundTest), inputContents); + } + + [Test] + public Task InitListForArrayTest() + { + var inputContents = @" +void MyFunction() +{ + int x[4] = { 1, 2, 3, 4 }; + int y[4] = { 1, 2, 3 }; + int z[] = { 1, 2 }; +} +"; + + return ValidateAsync(nameof(InitListForArrayTest), inputContents); + } + + [Test] + public Task InitListForRecordDeclTest() + { + var inputContents = @"struct MyStruct +{ + float x; + float y; + float z; + float w; +}; + +MyStruct MyFunction1() +{ + return { 1.0f, 2.0f, 3.0f, 4.0f }; +} + +MyStruct MyFunction2() +{ + return { 1.0f, 2.0f, 3.0f }; +} +"; + + return ValidateAsync(nameof(InitListForRecordDeclTest), inputContents); + } + + [Test] + public Task MemberTest() + { + var inputContents = @"struct MyStruct +{ + int value; +}; + +int MyFunction1(MyStruct instance) +{ + return instance.value; +} + +int MyFunction2(MyStruct* instance) +{ + return instance->value; +} +"; + + return ValidateAsync(nameof(MemberTest), inputContents); + } + + [Test] + public Task RefToPtrTest() + { + var inputContents = @"struct MyStruct { + int value; +}; + +bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) +{ + return lhs.value == rhs.value; +} +"; + + return ValidateAsync(nameof(RefToPtrTest), inputContents); + } + + [Test] + public Task ReturnCXXNullPtrTest() + { + var inputContents = @"void* MyFunction() +{ + return nullptr; +} +"; + + return ValidateAsync(nameof(ReturnCXXNullPtrTest), inputContents); + } + + [TestCase("false")] + [TestCase("true")] + public Task ReturnCXXBooleanLiteralTest(string value) + { + var inputContents = $@"bool MyFunction() +{{ + return {value}; +}} +"; + + return ValidateAsync(nameof(ReturnCXXBooleanLiteralTest), inputContents, discriminator: $"{value}"); + } + + [TestCase("5e-1")] + [TestCase("3.14")] + public Task ReturnFloatingLiteralDoubleTest(string value) + { + var inputContents = $@"double MyFunction() +{{ + return {value}; +}} +"; + + return ValidateAsync(nameof(ReturnFloatingLiteralDoubleTest), inputContents, discriminator: $"{value}"); + } + + [TestCase("5e-1f")] + [TestCase("3.14f")] + public Task ReturnFloatingLiteralSingleTest(string value) + { + var inputContents = $@"float MyFunction() +{{ + return {value}; +}} +"; + + return ValidateAsync(nameof(ReturnFloatingLiteralSingleTest), inputContents, discriminator: $"{value}"); + } + + [Test] + public Task ReturnEmptyTest() + { + var inputContents = @"void MyFunction() +{ + return; +} +"; + + return ValidateAsync(nameof(ReturnEmptyTest), inputContents); + } + + [Test] + public Task ReturnIntegerLiteralInt32Test() + { + var inputContents = @"int MyFunction() +{ + return -1; +} +"; + + return ValidateAsync(nameof(ReturnIntegerLiteralInt32Test), inputContents); + } + + [Test] + public Task ReturnStructTest() + { + var inputContents = @"struct MyStruct +{ + double r; + double g; + double b; +}; + +MyStruct MyFunction() +{ + MyStruct myStruct; + return myStruct; +} +"; + + return ValidateAsync(nameof(ReturnStructTest), inputContents); + } + + [Test] + public Task SwitchTest() + { + var inputContents = @"int MyFunction(int value) +{ + switch (value) + { + default: + { + return 0; + } + } +} +"; + + return ValidateAsync(nameof(SwitchTest), inputContents); + } + + [Test] + public Task SwitchNonCompoundTest() + { + var inputContents = @"int MyFunction(int value) +{ + switch (value) + default: + { + return 0; + } + + switch (value) + default: + return 0; +} +"; + + return ValidateAsync(nameof(SwitchNonCompoundTest), inputContents); + } + + [Test] + public Task UnaryOperatorAddrOfTest() + { + var inputContents = @"int* MyFunction(int value) +{ + return &value; +} +"; + + return ValidateAsync(nameof(UnaryOperatorAddrOfTest), inputContents); + } + + [Test] + public Task UnaryOperatorDerefTest() + { + var inputContents = @"int MyFunction(int* value) +{ + return *value; +} +"; + + return ValidateAsync(nameof(UnaryOperatorDerefTest), inputContents); + } + + [Test] + public Task UnaryOperatorLogicalNotTest() + { + var inputContents = @"bool MyFunction(bool value) +{ + return !value; +} +"; + + return ValidateAsync(nameof(UnaryOperatorLogicalNotTest), inputContents); + } + + [TestCase("++")] + [TestCase("--")] + public Task UnaryOperatorPostfixTest(string opcode) + { + var inputContents = $@"int MyFunction(int value) +{{ + return value{opcode}; +}} +"; + + return ValidateAsync(nameof(UnaryOperatorPostfixTest), inputContents, discriminator: $"{opcode}"); + } + + [TestCase("+")] + [TestCase("++")] + [TestCase("-")] + [TestCase("--")] + [TestCase("~")] + public Task UnaryOperatorPrefixTest(string opcode) + { + var inputContents = $@"int MyFunction(int value) +{{ + return {opcode}value; +}} +"; + + return ValidateAsync(nameof(UnaryOperatorPrefixTest), inputContents, discriminator: $"{opcode}"); + } + + [Test] + public Task WhileTest() + { + var inputContents = @"int MyFunction(int count) +{ + int i = 0; + + while (i < count) + { + i++; + } + + return i; +} +"; + + return ValidateAsync(nameof(WhileTest), inputContents); + } + + [Test] + public Task WhileNonCompoundTest() + { + var inputContents = @"int MyFunction(int count) +{ + int i = 0; + + while (i < count) + i++; + + return i; +} +"; + + return ValidateAsync(nameof(WhileNonCompoundTest), inputContents); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/FunctionDeclarationDllImportTest.cs new file mode 100644 index 00000000..200b76d2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/FunctionDeclarationDllImportTest.cs @@ -0,0 +1,220 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System.Collections.Generic; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace ClangSharp.UnitTests.Baseline; + +[TestFixtureSource(nameof(Variants))] +public sealed class FunctionDeclarationDllImportTest : BaselineTest +{ + private static readonly string[] TemplateTestExcludedNames = ["MyTemplate"]; + + public FunctionDeclarationDllImportTest(BaselineVariant variant) : base(variant) + { + } + + protected override string Area => "FunctionDeclarationDllImport"; + + [Test] + public Task BasicTest() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + return ValidateAsync(nameof(BasicTest), inputContents); + } + + [Test] + public Task ArrayParameterTest() + { + var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; + + return ValidateAsync(nameof(ArrayParameterTest), inputContents); + } + + [Test] + public Task FunctionPointerParameterTest() + { + var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; + + return ValidateAsync(nameof(FunctionPointerParameterTest), inputContents); + } + + [Test] + public Task NamespaceTest() + { + var inputContents = @"namespace MyNamespace +{ + void MyFunction(); +}"; + + return ValidateAsync(nameof(NamespaceTest), inputContents); + } + + [TestCase("int", false, "int", "")] + [TestCase("bool", true, "byte", "")] + [TestCase("float *", true, "IntPtr", "using System;\n")] + [TestCase("void (*)(int)", true, "IntPtr", "using System;\n")] + public Task TemplateParameterTest(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) + { + var inputContents = @$"template struct MyTemplate; + +extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; + + return ValidateAsync(nameof(TemplateParameterTest), inputContents, discriminator: $"{nativeType}_{expectedNativeTypeAttr}_{expectedManagedType}_{expectedUsingStatement}", excludedNames: TemplateTestExcludedNames); + } + + [Test] + public Task TemplateMemberTest() + { + var inputContents = @$"template struct MyTemplate +{{ +}}; + +struct MyStruct +{{ + MyTemplate a; +}}; +"; + + return ValidateAsync(nameof(TemplateMemberTest), inputContents, excludedNames: TemplateTestExcludedNames); + } + + [Test] + public Task NoLibraryPathTest() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + return ValidateAsync(nameof(NoLibraryPathTest), inputContents, libraryPath: string.Empty); + } + + [Test] + public Task WithLibraryPathTest() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + var withLibraryPaths = new Dictionary + { + ["MyFunction"] = "ClangSharpPInvokeGenerator" + }; + return ValidateAsync(nameof(WithLibraryPathTest), inputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } + + [Test] + public Task WithLibraryPathStarTest() + { + var inputContents = @"extern ""C"" void MyFunction();"; + + var withLibraryPaths = new Dictionary + { + ["*"] = "ClangSharpPInvokeGenerator" + }; + return ValidateAsync(nameof(WithLibraryPathStarTest), inputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); + } + + [TestCase("unsigned char", "0", true, "byte", "0")] + [TestCase("double", "1.0", false, "double", "1.0")] + [TestCase("short", "2", false, "short", "2")] + [TestCase("int", "3", false, "int", "3")] + [TestCase("long long", "4", true, "long", "4")] + [TestCase("signed char", "5", true, "sbyte", "5")] + [TestCase("float", "6.0f", false, "float", "6.0f")] + [TestCase("unsigned short", "7", true, "ushort", "7")] + [TestCase("unsigned int", "8", true, "uint", "8")] + [TestCase("unsigned long long", "9", true, "ulong", "9")] + [TestCase("unsigned short", "'A'", true, "ushort", "(byte)('A')")] + public Task OptionalParameterTest(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + + return ValidateAsync(nameof(OptionalParameterTest), inputContents, discriminator: $"{nativeType}_{nativeInit}_{expectedNativeTypeNameAttr}_{expectedManagedType}_{expectedManagedInit}"); + } + + [TestCase("void *", "nullptr", "void*", "null")] + [TestCase("void *", "0", "void*", "null")] + public Task OptionalParameterUnsafeTest(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) + { + var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; + + return ValidateAsync(nameof(OptionalParameterUnsafeTest), inputContents, discriminator: $"{nativeType}_{nativeInit}_{expectedManagedType}_{expectedManagedInit}"); + } + + [Test] + public Task WithCallConvTest() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var withCallConvs = new Dictionary { + ["MyFunction1"] = "Winapi" + }; + return ValidateAsync(nameof(WithCallConvTest), inputContents, withCallConvs: withCallConvs); + } + + [Test] + public Task WithCallConvStarTest() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var withCallConvs = new Dictionary + { + ["*"] = "Winapi" + }; + return ValidateAsync(nameof(WithCallConvStarTest), inputContents, withCallConvs: withCallConvs); + } + + [Test] + public Task WithCallConvStarOverrideTest() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + var withCallConvs = new Dictionary + { + ["*"] = "Winapi", + ["MyFunction2"] = "StdCall" + }; + return ValidateAsync(nameof(WithCallConvStarOverrideTest), inputContents, withCallConvs: withCallConvs); + } + + [Test] + public Task WithSetLastErrorTest() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + string[] withSetLastErrors = ["MyFunction1"]; + return ValidateAsync(nameof(WithSetLastErrorTest), inputContents, withSetLastErrors: withSetLastErrors); + } + + [Test] + public Task WithSetLastErrorStarTest() + { + var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; + + string[] withSetLastErrors = ["*"]; + return ValidateAsync(nameof(WithSetLastErrorStarTest), inputContents, withSetLastErrors: withSetLastErrors); + } + + [Test] + public Task SourceLocationTest() + => ValidateAsync(nameof(SourceLocationTest), @"extern ""C"" void MyFunction(float value);", additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); + + [Test] + public Task VarargsTest() + { + // Legacy only exercised __arglist output for CSharp on Windows; every Xml variant and every Unix variant + // stubbed VarargsTestImpl to Task.CompletedTask (no assertion at all). Preserve that coverage exactly here. + // This is a genuine legacy coverage gap -- surfaced, not silently widened -- since Xml/Unix __arglist output + // was never asserted (and Unix output cannot be reproduced on a Windows host to seed a baseline). + if (Variant.Mode != PInvokeGeneratorOutputMode.CSharp || Variant.Os != BaselineOs.Windows) + { + return Task.CompletedTask; + } + + return ValidateAsync(nameof(VarargsTest), @"extern ""C"" void MyFunction(int value, ...);"); + } + + [Test] + public Task IntrinsicsTest() + => ValidateAsync(nameof(IntrinsicsTest), @"extern ""C"" void __builtin_cpu_init(); +#pragma intrinsic(__builtin_cpu_init)"); +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/FunctionPointerDeclarationTest.cs new file mode 100644 index 00000000..bd9b8f8e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/FunctionPointerDeclarationTest.cs @@ -0,0 +1,46 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System.Threading.Tasks; +using NUnit.Framework; + +namespace ClangSharp.UnitTests.Baseline; + +// FunctionPointerDeclarationTest migrated to the baseline model. One fixture, parameterized over all 16 +// variants; each case declares its C/C++ input exactly once and the expected output lives in a checked-in +// baseline file. +[TestFixtureSource(nameof(Variants))] +public sealed class FunctionPointerDeclarationTest : BaselineTest +{ + public FunctionPointerDeclarationTest(BaselineVariant variant) : base(variant) + { + } + + protected override string Area => "FunctionPointerDeclaration"; + + [Test] + public Task BasicTest() + => ValidateAsync(nameof(BasicTest), @"typedef void (*Callback)(); + +struct MyStruct { + Callback _callback; +}; +"); + + [Test] + public Task CallconvTest() + => ValidateAsync(nameof(CallconvTest), @"typedef void (*Callback)() __attribute__((stdcall)); + +struct MyStruct { + Callback _callback; +}; +"); + + [Test] + public Task PointerlessTypedefTest() + => ValidateAsync(nameof(PointerlessTypedefTest), @"typedef void (Callback)(); + +struct MyStruct { + Callback* _callback; +}; +"); +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/StructDeclarationTest.cs new file mode 100644 index 00000000..cc4c34f0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/StructDeclarationTest.cs @@ -0,0 +1,831 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System.Collections.Generic; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace ClangSharp.UnitTests.Baseline; + +[TestFixtureSource(nameof(Variants))] +public sealed class StructDeclarationTest : BaselineTest +{ + private static readonly string[] ExcludeTestExcludedNames = ["MyStruct"]; + private static readonly string[] GuidTestExcludedNames = ["DECLSPEC_UUID"]; + + public StructDeclarationTest(BaselineVariant variant) : base(variant) + { + } + + protected override string Area => "StructDeclaration"; + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task IncompleteArraySizeTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct +{{ + {nativeType} x[]; +}}; +"; + + return ValidateAsync(nameof(IncompleteArraySizeTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task BasicTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; +}}; +"; + + return ValidateAsync(nameof(BasicTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task BasicTestInCMode(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; +}} MyStruct; +"; + + return ValidateAsync(nameof(BasicTestInCMode), inputContents, discriminator: $"{nativeType}_{expectedManagedType}", commandLineArgs: []); + } + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task BasicWithNativeTypeNameTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; +}}; +"; + + return ValidateAsync(nameof(BasicWithNativeTypeNameTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [Test] + public Task BitfieldTest() + { + var inputContents = @"struct MyStruct1 +{ + unsigned int o0_b0_24 : 24; + unsigned int o4_b0_16 : 16; + unsigned int o4_b16_3 : 3; + int o4_b19_3 : 3; + unsigned char o8_b0_1 : 1; + int o12_b0_1 : 1; + int o12_b1_1 : 1; +}; + +struct MyStruct2 +{ + unsigned int o0_b0_1 : 1; + int x; + unsigned int o8_b0_1 : 1; +}; + +struct MyStruct3 +{ + unsigned int o0_b0_1 : 1; + unsigned int o0_b1_1 : 1; +}; +"; + + return ValidateAsync(nameof(BitfieldTest), inputContents); + } + + [Test] + public Task BitfieldWithNativeBitfieldAttributeTest() + { + var inputContents = @"struct MyStruct1 +{ + unsigned int o0_b0_24 : 24; + unsigned int o4_b0_16 : 16; + unsigned int o4_b16_3 : 3; + int o4_b19_3 : 3; + unsigned char o8_b0_1 : 1; + int o12_b0_1 : 1; + int o12_b1_1 : 1; +}; + +struct MyStruct2 +{ + unsigned int o0_b0_1 : 1; + int x; + unsigned int o8_b0_1 : 1; +}; + +struct MyStruct3 +{ + unsigned int o0_b0_1 : 1; + unsigned int o0_b1_1 : 1; +}; +"; + + return ValidateAsync(nameof(BitfieldWithNativeBitfieldAttributeTest), inputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); + } + + [Test] + public Task DeclTypeTest() + { + var inputContents = @"extern ""C"" void MyFunction(); + +typedef struct +{ + decltype(&MyFunction) _callback; +} MyStruct; +"; + + return ValidateAsync(nameof(DeclTypeTest), inputContents); + } + + [Test] + public Task ExcludeTest() + { + var inputContents = "typedef struct MyStruct MyStruct;"; + + return ValidateAsync(nameof(ExcludeTest), inputContents, excludedNames: ExcludeTestExcludedNames); + } + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task FixedSizedBufferNonPrimitiveTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct +{{ + {nativeType} value; +}}; + +struct MyOtherStruct +{{ + MyStruct c[3]; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferNonPrimitiveTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task FixedSizedBufferNonPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct +{{ + {nativeType} value; +}}; + +struct MyOtherStruct +{{ + MyStruct c[2][1][3][4]; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferNonPrimitiveMultidimensionalTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task FixedSizedBufferNonPrimitiveTypedefTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct +{{ + {nativeType} value; +}}; + +typedef MyStruct MyBuffer[3]; + +struct MyOtherStruct +{{ + MyBuffer c; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferNonPrimitiveTypedefTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct +{{ + {nativeType} value; +}}; + +struct MyOtherStruct +{{ + MyStruct c[3]; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferNonPrimitiveWithNativeTypeNameTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("double *", "double*")] + [TestCase("short *", "short*")] + [TestCase("int *", "int*")] + [TestCase("float *", "float*")] + public Task FixedSizedBufferPointerTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct +{{ + {nativeType} c[3]; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferPointerTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + public Task FixedSizedBufferPrimitiveTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct +{{ + {nativeType} c[3]; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferPrimitiveTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + public Task FixedSizedBufferPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct +{{ + {nativeType} c[2][1][3][4]; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferPrimitiveMultidimensionalTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + public Task FixedSizedBufferPrimitiveTypedefTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; + +struct MyStruct +{{ + MyBuffer c; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferPrimitiveTypedefTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [Test] + public Task GuidTest() + { + if (Variant.Os != BaselineOs.Windows) + { + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } + + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + +struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 +{{ + int x; +}}; + +struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 +{{ + int x; +}}; +"; + + return ValidateAsync(nameof(GuidTest), inputContents, excludedNames: GuidTestExcludedNames); + } + + [Test] + public Task InheritanceTest() + { + var inputContents = @"struct MyStruct1A +{ + int x; + int y; +}; + +struct MyStruct1B +{ + int x; + int y; +}; + +struct MyStruct2 : MyStruct1A, MyStruct1B +{ + int z; + int w; +}; +"; + + return ValidateAsync(nameof(InheritanceTest), inputContents); + } + + [Test] + public Task InheritanceWithNativeInheritanceAttributeTest() + { + var inputContents = @"struct MyStruct1A +{ + int x; + int y; +}; + +struct MyStruct1B +{ + int x; + int y; +}; + +struct MyStruct2 : MyStruct1A, MyStruct1B +{ + int z; + int w; +}; +"; + + return ValidateAsync(nameof(InheritanceWithNativeInheritanceAttributeTest), inputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); + } + + [TestCase("double", "double", 10, 5)] + [TestCase("short", "short", 10, 5)] + [TestCase("int", "int", 10, 5)] + [TestCase("float", "float", 10, 5)] + public Task NestedAnonymousTest(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef union {{ + {nativeType} value; +}} MyUnion; + +struct MyStruct +{{ + {nativeType} x; + {nativeType} y; + + struct + {{ + {nativeType} z; + + struct + {{ + {nativeType} value; + }} w; + + struct + {{ + {nativeType} value1; + + struct + {{ + {nativeType} value; + }}; + }}; + + union + {{ + {nativeType} value2; + }}; + + MyUnion u; + {nativeType} buffer1[4]; + MyUnion buffer2[4]; + }}; +}}; +"; + + return ValidateAsync(nameof(NestedAnonymousTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}_{line}_{column}"); + } + + [Test] + public Task NestedAnonymousWithBitfieldTest() + { + var inputContents = @"struct MyStruct +{ + int x; + int y; + + struct + { + int z; + + struct + { + int w; + int o0_b0_16 : 16; + int o0_b16_4 : 4; + }; + }; +}; +"; + + return ValidateAsync(nameof(NestedAnonymousWithBitfieldTest), inputContents); + } + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task NestedTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; + + struct MyNestedStruct + {{ + {nativeType} r; + {nativeType} g; + {nativeType} b; + {nativeType} a; + }}; +}}; +"; + + return ValidateAsync(nameof(NestedTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task NestedWithNativeTypeNameTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"struct MyStruct +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; + + struct MyNestedStruct + {{ + {nativeType} r; + {nativeType} g; + {nativeType} b; + {nativeType} a; + }}; +}}; +"; + + return ValidateAsync(nameof(NestedWithNativeTypeNameTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [Test] + public Task NewKeywordTest() + { + var inputContents = @"struct MyStruct +{ + int Equals; + int Dispose; + int GetHashCode; + int GetType; + int MemberwiseClone; + int ReferenceEquals; + int ToString; +};"; + + return ValidateAsync(nameof(NewKeywordTest), inputContents); + } + + [Test] + public Task NoDefinitionTest() + { + var inputContents = "typedef struct MyStruct MyStruct;"; + + return ValidateAsync(nameof(NoDefinitionTest), inputContents); + } + + [Test] + public Task PackTest() + { + return ValidateAsync(nameof(PackTest), @"struct MyStruct1 { + unsigned Field1; + + void* Field2; + + unsigned Field3; +}; + +#pragma pack(4) + +struct MyStruct2 { + unsigned Field1; + + void* Field2; + + unsigned Field3; +}; +"); + } + + [Test] + public Task PointerToSelfTest() + { + var inputContents = @"struct example_s { + example_s* next; + void* data; +};"; + + return ValidateAsync(nameof(PointerToSelfTest), inputContents); + } + + [Test] + public Task PointerToSelfViaTypedefTest() + { + var inputContents = @"typedef struct example_s example_t; + +struct example_s { + example_t* next; + void* data; +};"; + + return ValidateAsync(nameof(PointerToSelfViaTypedefTest), inputContents); + } + + [Test] + public Task RemapTest() + { + var inputContents = "typedef struct _MyStruct MyStruct;"; + + var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; + return ValidateAsync(nameof(RemapTest), inputContents, remappedNames: remappedNames); + } + + [Test] + public Task RemapNestedAnonymousTest() + { + var inputContents = @"struct MyStruct +{ + double r; + double g; + double b; + + struct + { + double a; + }; +};"; + + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" + }; + return ValidateAsync(nameof(RemapNestedAnonymousTest), inputContents, remappedNames: remappedNames); + } + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task SkipNonDefinitionTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; + +struct MyStruct +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; +}}; +"; + + return ValidateAsync(nameof(SkipNonDefinitionTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [Test] + public Task SkipNonDefinitionPointerTest() + { + var inputContents = @"typedef struct MyStruct* MyStructPtr; +typedef struct MyStruct& MyStructRef; +"; + + return ValidateAsync(nameof(SkipNonDefinitionPointerTest), inputContents); + } + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task SkipNonDefinitionWithNativeTypeNameTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef struct MyStruct MyStruct; + +struct MyStruct +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; +}}; +"; + + return ValidateAsync(nameof(SkipNonDefinitionWithNativeTypeNameTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task TypedefTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; + +struct MyStruct +{{ + MyTypedefAlias r; + MyTypedefAlias g; + MyTypedefAlias b; +}}; +"; + + return ValidateAsync(nameof(TypedefTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [Test] + public Task UsingDeclarationTest() + { + var inputContents = @"struct MyStruct1A +{ + void MyMethod() { } +}; + +struct MyStruct1B : MyStruct1A +{ + using MyStruct1A::MyMethod; +}; +"; + + return ValidateAsync(nameof(UsingDeclarationTest), inputContents); + } + + [Test] + public Task WithAccessSpecifierTest() + { + var inputContents = @"struct MyStruct1 +{ + int Field1; + int Field2; +}; + +struct MyStruct2 +{ + int Field1; + int Field2; +}; + +struct MyStruct3 +{ + int Field1; + int Field2; +}; +"; + + var withAccessSpecifiers = new Dictionary { + ["MyStruct1"] = AccessSpecifier.Private, + ["MyStruct2"] = AccessSpecifier.Internal, + ["Field1"] = AccessSpecifier.Private, + ["MyStruct3.Field2"] = AccessSpecifier.Internal, + }; + return ValidateAsync(nameof(WithAccessSpecifierTest), inputContents, withAccessSpecifiers: withAccessSpecifiers); + } + + [Test] + public Task WithPackingTest() + { + var withPackings = new Dictionary { + ["MyStruct"] = "CustomPackValue" + }; + + // Non-Windows targets don't predefine size_t for a header-only parse, so the Unix variants declare it + // (matching the legacy per-OS input); the resulting int-sized member also exercises the Unix layout. + var inputContents = Variant.Os == BaselineOs.Unix ? @"typedef int size_t; + +struct MyStruct +{ + size_t FixedBuffer[2]; +}; +" : @"struct MyStruct +{ + size_t FixedBuffer[2]; +}; +"; + + return ValidateAsync(nameof(WithPackingTest), inputContents, withPackings: withPackings); + } + + [Test] + public Task SourceLocationAttributeTest() + { + return ValidateAsync(nameof(SourceLocationAttributeTest), @"struct MyStruct +{ + int r; + int g; + int b; +}; +", additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); + } + + [Test] + public Task AnonStructAndAnonStructArray() + { + var inputContents = @"typedef struct _MyStruct +{ + struct { int First; }; + struct { int Second; } MyArray[2]; +} MyStruct; +"; + + return ValidateAsync(nameof(AnonStructAndAnonStructArray), inputContents); + } + + [Test] + public Task DeeplyNestedAnonStructs() + { + var inputContents = @"typedef struct _MyStruct +{ + struct { struct { + struct { int Value1; }; + struct { int Value2; }; + }; }; +} MyStruct;"; + + return ValidateAsync(nameof(DeeplyNestedAnonStructs), inputContents); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/UnionDeclarationTest.cs new file mode 100644 index 00000000..be147016 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/UnionDeclarationTest.cs @@ -0,0 +1,593 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System.Collections.Generic; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace ClangSharp.UnitTests.Baseline; + +[TestFixtureSource(nameof(Variants))] +public sealed class UnionDeclarationTest : BaselineTest +{ + private static readonly string[] ExcludeTestExcludedNames = ["MyUnion"]; + private static readonly string[] GuidTestExcludedNames = ["DECLSPEC_UUID"]; + + public UnionDeclarationTest(BaselineVariant variant) : base(variant) + { + } + + protected override string Area => "UnionDeclaration"; + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task BasicTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; +}}; +"; + + return ValidateAsync(nameof(BasicTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task BasicTestInCMode(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; +}} MyUnion; +"; + + return ValidateAsync(nameof(BasicTestInCMode), inputContents, discriminator: $"{nativeType}_{expectedManagedType}", commandLineArgs: []); + } + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task BasicWithNativeTypeNameTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; +}}; +"; + + return ValidateAsync(nameof(BasicWithNativeTypeNameTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [Test] + public Task BitfieldTest() + { + var inputContents = @"union MyUnion1 +{ + unsigned int o0_b0_24 : 24; + unsigned int o4_b0_16 : 16; + unsigned int o4_b16_3 : 3; + int o4_b19_3 : 3; + unsigned char o8_b0_1 : 1; + int o12_b0_1 : 1; + int o12_b1_1 : 1; +}; + +union MyUnion2 +{ + unsigned int o0_b0_1 : 1; + int x; + unsigned int o8_b0_1 : 1; +}; + +union MyUnion3 +{ + unsigned int o0_b0_1 : 1; + unsigned int o0_b1_1 : 1; +}; +"; + + return ValidateAsync(nameof(BitfieldTest), inputContents); + } + + [Test] + public Task ExcludeTest() + { + var inputContents = "typedef union MyUnion MyUnion;"; + return ValidateAsync(nameof(ExcludeTest), inputContents, excludedNames: ExcludeTestExcludedNames); + } + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task FixedSizedBufferNonPrimitiveTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion +{{ + {nativeType} value; +}}; + +union MyOtherUnion +{{ + MyUnion c[3]; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferNonPrimitiveTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task FixedSizedBufferNonPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion +{{ + {nativeType} value; +}}; + +union MyOtherUnion +{{ + MyUnion c[2][1][3][4]; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferNonPrimitiveMultidimensionalTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task FixedSizedBufferNonPrimitiveTypedefTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion +{{ + {nativeType} value; +}}; + +typedef MyUnion MyBuffer[3]; + +union MyOtherUnion +{{ + MyBuffer c; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferNonPrimitiveTypedefTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion +{{ + {nativeType} value; +}}; + +union MyOtherUnion +{{ + MyUnion c[3]; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferNonPrimitiveWithNativeTypeNameTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("double *", "double*")] + [TestCase("short *", "short*")] + [TestCase("int *", "int*")] + [TestCase("float *", "float*")] + public Task FixedSizedBufferPointerTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion +{{ + {nativeType} c[3]; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferPointerTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + public Task FixedSizedBufferPrimitiveTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion +{{ + {nativeType} c[3]; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferPrimitiveTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + public Task FixedSizedBufferPrimitiveMultidimensionalTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion +{{ + {nativeType} c[2][1][3][4]; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferPrimitiveMultidimensionalTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + public Task FixedSizedBufferPrimitiveTypedefTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyBuffer[3]; + +union MyUnion +{{ + MyBuffer c; +}}; +"; + + return ValidateAsync(nameof(FixedSizedBufferPrimitiveTypedefTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [Test] + public Task GuidTest() + { + if (Variant.Os != BaselineOs.Windows) + { + // Non-Windows doesn't support __declspec(uuid("")) + return Task.CompletedTask; + } + + var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) + +union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 +{{ + int x; +}}; + +union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 +{{ + int x; +}}; +"; + + return ValidateAsync(nameof(GuidTest), inputContents, excludedNames: GuidTestExcludedNames); + } + + [TestCase("double", "double", 11, 5)] + [TestCase("short", "short", 11, 5)] + [TestCase("int", "int", 11, 5)] + [TestCase("float", "float", 11, 5)] + public Task NestedAnonymousTest(string nativeType, string expectedManagedType, int line, int column) + { + var inputContents = $@"typedef struct {{ + {nativeType} value; +}} MyStruct; + +union MyUnion +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; + + union + {{ + {nativeType} a; + + MyStruct s; + + {nativeType} buffer[4]; + }}; +}}; +"; + + return ValidateAsync(nameof(NestedAnonymousTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}_{line}_{column}"); + } + + [Test] + public Task NestedAnonymousWithBitfieldTest() + { + var inputContents = @"union MyUnion +{ + int x; + int y; + + union + { + int z; + + union + { + int w; + int o0_b0_16 : 16; + int o0_b16_4 : 4; + }; + }; +}; +"; + + return ValidateAsync(nameof(NestedAnonymousWithBitfieldTest), inputContents); + } + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task NestedTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; + + union MyNestedUnion + {{ + {nativeType} r; + {nativeType} g; + {nativeType} b; + {nativeType} a; + }}; +}}; +"; + + return ValidateAsync(nameof(NestedTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task NestedWithNativeTypeNameTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"union MyUnion +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; + + union MyNestedUnion + {{ + {nativeType} r; + {nativeType} g; + {nativeType} b; + {nativeType} a; + }}; +}}; +"; + + return ValidateAsync(nameof(NestedWithNativeTypeNameTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [Test] + public Task NewKeywordTest() + { + var inputContents = @"union MyUnion +{ + int Equals; + int Dispose; + int GetHashCode; + int GetType; + int MemberwiseClone; + int ReferenceEquals; + int ToString; +};"; + + return ValidateAsync(nameof(NewKeywordTest), inputContents); + } + + [Test] + public Task NoDefinitionTest() + { + var inputContents = "typedef union MyUnion MyUnion;"; + return ValidateAsync(nameof(NoDefinitionTest), inputContents); + } + + [Test] + public Task PointerToSelfTest() + { + var inputContents = @"union example_s { + example_s* next; + void* data; +};"; + + return ValidateAsync(nameof(PointerToSelfTest), inputContents); + } + + [Test] + public Task PointerToSelfViaTypedefTest() + { + var inputContents = @"typedef union example_s example_t; + +union example_s { + example_t* next; + void* data; +};"; + + return ValidateAsync(nameof(PointerToSelfViaTypedefTest), inputContents); + } + + [Test] + public Task RemapTest() + { + var inputContents = "typedef union _MyUnion MyUnion;"; + + var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; + return ValidateAsync(nameof(RemapTest), inputContents, remappedNames: remappedNames); + } + + [Test] + public Task RemapNestedAnonymousTest() + { + var inputContents = @"union MyUnion +{ + double r; + double g; + double b; + + union + { + double a; + }; +};"; + + var remappedNames = new Dictionary { + ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", + ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" + }; + return ValidateAsync(nameof(RemapNestedAnonymousTest), inputContents, remappedNames: remappedNames); + } + + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("float", "float")] + public Task SkipNonDefinitionTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; + +union MyUnion +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; +}}; +"; + + return ValidateAsync(nameof(SkipNonDefinitionTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [Test] + public Task SkipNonDefinitionPointerTest() + { + var inputContents = @"typedef union MyUnion* MyUnionPtr; +typedef union MyUnion& MyUnionRef; +"; + + return ValidateAsync(nameof(SkipNonDefinitionPointerTest), inputContents); + } + + [TestCase("unsigned char", "byte")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task SkipNonDefinitionWithNativeTypeNameTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef union MyUnion MyUnion; + +union MyUnion +{{ + {nativeType} r; + {nativeType} g; + {nativeType} b; +}}; +"; + + return ValidateAsync(nameof(SkipNonDefinitionWithNativeTypeNameTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [TestCase("unsigned char", "byte")] + [TestCase("double", "double")] + [TestCase("short", "short")] + [TestCase("int", "int")] + [TestCase("long long", "long")] + [TestCase("signed char", "sbyte")] + [TestCase("float", "float")] + [TestCase("unsigned short", "ushort")] + [TestCase("unsigned int", "uint")] + [TestCase("unsigned long long", "ulong")] + [TestCase("bool", "byte")] + public Task TypedefTest(string nativeType, string expectedManagedType) + { + var inputContents = $@"typedef {nativeType} MyTypedefAlias; + +union MyUnion +{{ + MyTypedefAlias r; + MyTypedefAlias g; + MyTypedefAlias b; +}}; +"; + + return ValidateAsync(nameof(TypedefTest), inputContents, discriminator: $"{nativeType}_{expectedManagedType}"); + } + + [Test] + public Task UnionWithAnonStructWithAnonUnion() + { + var inputContents = $@"typedef union _MY_UNION +{{ + long AsArray[2]; + struct + {{ + long First; + union + {{ + struct + {{ + long Second; + }} A; + + struct + {{ + long Second; + }} B; + }}; + }}; +}} MY_UNION;"; + + return ValidateAsync(nameof(UnionWithAnonStructWithAnonUnion), inputContents); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/VarDeclarationTest.cs new file mode 100644 index 00000000..298fbcf2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/VarDeclarationTest.cs @@ -0,0 +1,157 @@ +// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +using System.Collections.Generic; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace ClangSharp.UnitTests.Baseline; + +// Proof-of-concept: VarDeclarationTest migrated to the baseline model. One fixture, parameterized over +// all 16 variants; each case declares its C/C++ input and options exactly once. Compare against the +// legacy shape: an abstract Base/VarDeclarationTest.cs plus 16 near-identical folder copies. +[TestFixtureSource(nameof(Variants))] +public sealed class VarDeclarationTest : BaselineTest +{ + private static readonly string[] GuidMacroTestExcludedNames = ["GUID"]; + private static readonly string[] UncheckedConversionMacroTest2ExcludedNames = ["MyMacro1", "MyMacro2"]; + + public VarDeclarationTest(BaselineVariant variant) : base(variant) + { + } + + protected override string Area => "VarDeclaration"; + + [TestCase("double")] + [TestCase("short")] + [TestCase("int")] + [TestCase("float")] + public Task BasicTest(string nativeType) + => ValidateAsync(nameof(BasicTest), $@"{nativeType} MyVariable = 0;", discriminator: nativeType); + + [TestCase("unsigned char")] + [TestCase("long long")] + [TestCase("signed char")] + [TestCase("unsigned short")] + [TestCase("unsigned int")] + [TestCase("unsigned long long")] + public Task BasicWithNativeTypeNameTest(string nativeType) + => ValidateAsync(nameof(BasicWithNativeTypeNameTest), $@"{nativeType} MyVariable = 0;", discriminator: nativeType); + + [Test] + public Task GuidMacroTest() + { + var inputContents = @"struct GUID { + unsigned long Data1; + unsigned short Data2; + unsigned short Data3; + unsigned char Data4[8]; +}; + +const GUID IID_IUnknown = { 0x00000000, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } }; +"; + + var remappedNames = new Dictionary { ["GUID"] = "Guid" }; + return ValidateAsync(nameof(GuidMacroTest), inputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); + } + + [TestCase("0")] + [TestCase("0U")] + [TestCase("0LL")] + [TestCase("0ULL")] + [TestCase("0LLU")] + [TestCase("0.0")] + [TestCase("0.f")] + public Task MacroTest(string nativeValue) + => ValidateAsync(nameof(MacroTest), $@"#define MyMacro1 {nativeValue} +#define MyMacro2 MyMacro1", discriminator: nativeValue); + + [Test] + public Task MultilineMacroTest() + => ValidateAsync(nameof(MultilineMacroTest), "#define MyMacro1 0 + \\\n1"); + + [TestCase("double")] + [TestCase("short")] + [TestCase("int")] + [TestCase("float")] + public Task NoInitializerTest(string nativeType) + => ValidateAsync(nameof(NoInitializerTest), $@"{nativeType} MyVariable;", discriminator: nativeType); + + [Test] + public Task Utf8StringLiteralMacroTest() + => ValidateAsync(nameof(Utf8StringLiteralMacroTest), @"#define MyMacro1 ""Test\0\\\r\n\t\"""""); + + [Test] + public Task Utf16StringLiteralMacroTest() + => ValidateAsync(nameof(Utf16StringLiteralMacroTest), @"#define MyMacro1 u""Test\0\\\r\n\t\"""""); + + [Test] + public Task WideStringLiteralConstTest() + => ValidateAsync(nameof(WideStringLiteralConstTest), @"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"); + + [Test] + public Task StringLiteralConstTest() + => ValidateAsync(nameof(StringLiteralConstTest), @"const char MyConst1[] = ""Test\0\\\r\n\t\""""; +const char* MyConst2 = ""Test\0\\\r\n\t\""""; +const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"); + + [Test] + public Task WideStringLiteralStaticConstTest() + => ValidateAsync(nameof(WideStringLiteralStaticConstTest), @"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; +static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; +static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"); + + [Test] + public Task StringLiteralStaticConstTest() + => ValidateAsync(nameof(StringLiteralStaticConstTest), @"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; +static const char* MyConst2 = ""Test\0\\\r\n\t\""""; +static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"); + + [Test] + public Task UncheckedConversionMacroTest() + => ValidateAsync(nameof(UncheckedConversionMacroTest), @"#define MyMacro1 (long)0x80000000L +#define MyMacro2 (int)0x80000000"); + + [Test] + public Task UncheckedFunctionLikeCastMacroTest() + => ValidateAsync(nameof(UncheckedFunctionLikeCastMacroTest), @"#define MyMacro1 unsigned(-1)"); + + [Test] + public Task UncheckedConversionMacroTest2() + => ValidateAsync(nameof(UncheckedConversionMacroTest2), @"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) +#define MyMacro2(n) MyMacro1(1, 2, n) +#define MyMacro3 MyMacro2(3)", excludedNames: UncheckedConversionMacroTest2ExcludedNames); + + [Test] + public Task UncheckedPointerMacroTest() + => ValidateAsync(nameof(UncheckedPointerMacroTest), @"#define Macro1 ((int*) -1)"); + + [Test] + public Task UncheckedReinterpretCastMacroTest() + => ValidateAsync(nameof(UncheckedReinterpretCastMacroTest), @"#define Macro1 reinterpret_cast(-1)"); + + [Test] + public Task MultidimensionlArrayTest() + => ValidateAsync(nameof(MultidimensionlArrayTest), @"const int MyArray[2][2] = { { 0, 1 }, { 2, 3 } };"); + + [Test] + public Task ConditionalDefineConstTest() + { + var inputContents = @"typedef int TESTRESULT; +#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) +#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; + + var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; + return ValidateAsync(nameof(ConditionalDefineConstTest), inputContents, expectedDiagnostics: diagnostics); + } + + [Test] + public Task UndefinedFunctionLikeMacroTest() + { + var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; + + var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; + return ValidateAsync(nameof(UndefinedFunctionLikeMacroTest), inputContents, expectedDiagnostics: diagnostics); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs deleted file mode 100644 index 509a92c0..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,532 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpCompatibleUnix_CXXMethodDeclarationTest : CXXMethodDeclarationCSharpTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [NativeTypeName(""struct MyStruct : MyTemplate"")] - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern int* DoWork(MyStruct* pThis, int* value = null); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(MyStruct* pThis); - - public int MyInt32Method() - {{ - return 0; - }} - - public void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType(MyStruct* pThis, int obj); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType1(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType2(MyStruct* pThis, int objA, int objB); - - public int GetType(int obj) - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType>((IntPtr)(lpVtbl[0]))(pThis, obj); - }} - }} - - public new int GetType() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType1>((IntPtr)(lpVtbl[1]))(pThis); - }} - }} - - public int GetType(int objA, int objB) - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType2>((IntPtr)(lpVtbl[2]))(pThis, objA, objB); - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public Vtbl* lpVtbl; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType(MyStruct* pThis, int obj); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType1(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType2(MyStruct* pThis, int objA, int objB); - - public int GetType(int obj) - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, obj); - }} - }} - - public new int GetType() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); - }} - }} - - public int GetType(int objA, int objB) - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, objA, objB); - }} - }} - - public partial struct Vtbl - {{ - [NativeTypeName(""int (int){nativeCallConv}"")] - public new IntPtr GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public IntPtr GetType1; - - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public IntPtr GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct : MyStruct.Interface - {{ - public Vtbl* lpVtbl; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType(MyStruct* pThis, int obj); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType1(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType2(MyStruct* pThis, int objA, int objB); - - public int GetType(int obj) - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, obj); - }} - }} - - public new int GetType() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); - }} - }} - - public int GetType(int objA, int objB) - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, objA, objB); - }} - }} - - public interface Interface - {{ - int GetType(int obj); - - int GetType(); - - int GetType(int objA, int objB); - }} - - public partial struct Vtbl - {{ - [NativeTypeName(""int (int){nativeCallConv}"")] - public new IntPtr GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public IntPtr GetType1; - - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public IntPtr GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(); - - public static int MyInt32Method() - {{ - return 0; - }} - - public static void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate void _MyVoidMethod(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - [return: NativeTypeName(""signed char"")] - public delegate sbyte _MyInt8Method(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _MyInt32Method(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate void* _MyVoidStarMethod(MyStruct* pThis); - - public void MyVoidMethod() - {{ - fixed (MyStruct* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyVoidMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - }} - - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt8Method>((IntPtr)(lpVtbl[1]))(pThis); - }} - }} - - public int MyInt32Method() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt32Method>((IntPtr)(lpVtbl[2]))(pThis); - }} - }} - - public void* MyVoidStarMethod() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyVoidStarMethod>((IntPtr)(lpVtbl[3]))(pThis); - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate void _MyVoidMethod(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - [return: NativeTypeName(""signed char"")] - public delegate sbyte _MyInt8Method(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _MyInt32Method(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate void* _MyVoidStarMethod(MyStruct* pThis); - - [VtblIndex(0)] - public void MyVoidMethod() - {{ - fixed (MyStruct* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyVoidMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - }} - - [VtblIndex(1)] - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt8Method>((IntPtr)(lpVtbl[1]))(pThis); - }} - }} - - [VtblIndex(2)] - public int MyInt32Method() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt32Method>((IntPtr)(lpVtbl[2]))(pThis); - }} - }} - - [VtblIndex(3)] - public void* MyVoidStarMethod() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyVoidStarMethod>((IntPtr)(lpVtbl[3]))(pThis); - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/DeprecatedToObsoleteTest.cs deleted file mode 100644 index 289cc350..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,521 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpCompatibleUnix_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - [Obsolete] - MyEnum_Value1, - [Obsolete(""This is obsolete."")] - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum0 - { - MyEnum_Value0, - } - - [Obsolete] - public enum MyEnum1 - { - MyEnum_Value1, - } - - [Obsolete(""This is obsolete."")] - public enum MyEnum2 - { - MyEnum_Value2, - } - - public enum MyEnum3 - { - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable0 = 0; - - [Obsolete] - public static {expectedManagedType} MyVariable1 = 0; - - [Obsolete(""This is obsolete."")] - public static {expectedManagedType} MyVariable2 = 0; - - public static {expectedManagedType} MyVariable3 = 0; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction0() - { - } - - [Obsolete] - public static void MyFunction1() - { - } - - [Obsolete(""This is obsolete."")] - public static void MyFunction2() - { - } - - public static void MyFunction3() - { - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public int MyFunction0() - {{ - return 0; - }} - - [Obsolete] - public int MyFunction1() - {{ - return 0; - }} - - [Obsolete(""This is obsolete."")] - public int MyFunction2() - {{ - return 0; - }} - - public int MyFunction3() - {{ - return 0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void Callback0(); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - [Obsolete] - public delegate void Callback1(); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - [Obsolete(""This is obsolete."")] - public delegate void Callback2(); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void Callback3(); - - public partial struct MyStruct0 - { - [NativeTypeName(""Callback0"")] - public IntPtr _callback; - } - - public partial struct MyStruct1 - { - [NativeTypeName(""Callback1"")] - [Obsolete] - public IntPtr _callback; - } - - public partial struct MyStruct2 - { - [NativeTypeName(""Callback2"")] - [Obsolete(""This is obsolete."")] - public IntPtr _callback; - } - - public partial struct MyStruct3 - { - [NativeTypeName(""Callback3"")] - public IntPtr _callback; - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction0(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete] - public static extern void MyFunction1(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete(""This is obsolete."")] - public static extern void MyFunction2(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction3(); - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/DigitsSeparatorTest.cs deleted file mode 100644 index b415d8c1..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/DigitsSeparatorTest.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.CSharpCompatibleUnix; - -[Platform("unix")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyClass - {{ - [NativeTypeName(""const {type}"")] - private const {type} x = {expectedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs deleted file mode 100644 index f6a5c169..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/EnumDeclarationTest.cs +++ /dev/null @@ -1,610 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpCompatibleUnix_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - [NativeTypeName(""{nativeType}"")] - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum1 : int -{ - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, -} MyEnum1; - -namespace Namespace1 -{ - namespace Namespace2 - { - typedef enum _MyEnum2 : int - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } MyEnum2; - - typedef enum _MyEnum3 : int - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } MyEnum3; - - typedef enum _MyEnum4 : int - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } MyEnum4; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, - } - - public enum MyEnum2 - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } - - public enum MyEnum3 - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } - - public enum MyEnum4 - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } -} -"; - - var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - [Flags] - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = 1, - } -} -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using System; -using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0 = (int)(MyEnum)(10), - MyEnum_Value1 = (int)(MyEnum)(MyEnum_Value0), - MyEnum_Value2 = ((int)(MyEnum)(10)) + MyEnum_Value1, - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0 = 10, - } - - public enum MyEnum2 - { - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (int)(MyEnum1)(10), - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = unchecked((int)(0x80000000)), - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, - } -} -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum1 : uint - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.Methods; - -namespace ClangSharp.Test -{ - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } - - public static partial class Methods - { - public const uint MyEnum1_Value1 = 1; - } -} -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public const uint MyEnum1_Value1 = 1; - - [NativeTypeName(""const int"")] - public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; - } -} -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index b7638e69..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,1795 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpCompatibleUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* pData, int index) - { - return pData[index]; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(bool x, bool y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - break; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction() - { - } - - public static void MyFunction() - { - MyCalledFunction(); - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction(int x, int y) - { - } - - public static void MyFunction() - { - MyCalledFunction(0, 1); - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 2: - case 3: - { - return 5; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } - - public static partial class Methods - { - public static int MyFunction(MyEnum x) - { - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - return condition ? lhs : rhs; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - continue; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction([NativeTypeName(""const void *"")] void* input) - { - return input; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStructA - {{ - public void** lpVtbl; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate void _MyMethod(MyStructA* pThis); - - public void MyMethod() - {{ - fixed (MyStructA* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - }} - }} - - [NativeTypeName(""struct MyStructB : MyStructA"")] - public unsafe partial struct MyStructB - {{ - public void** lpVtbl; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate void _MyMethod(MyStructB* pThis); - - public void MyMethod() - {{ - fixed (MyStructB* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - }} - }} - - public static unsafe partial class Methods - {{ - public static MyStructB* MyFunction(MyStructA* input) - {{ - return (MyStructB*)(input); - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - int x = 0; - int y = 1, z = 2; - - return x + y + z; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - - return rhs; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition1, int a, int b, bool condition2, int c) - { - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public float x; - - public float y; - - public float z; - - public float w; - } - - public static partial class Methods - { - public static MyStruct MyFunction1() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - } - - public static MyStruct MyFunction2() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static int MyFunction1(MyStruct instance) - { - return instance.value; - } - - public static int MyFunction2(MyStruct* instance) - { - return instance->value; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static bool MyFunction([NativeTypeName(""const MyStruct &"")] MyStruct* lhs, [NativeTypeName(""const MyStruct &"")] MyStruct* rhs) - { - return lhs->value == rhs->value; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction() - { - return null; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static double MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static float MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - return; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion - { - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - public ref int a - { - get - { - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->a; - } - } - } - - public partial struct _Anonymous_e__Struct - { - public int a; - } - } - - public static partial class Methods - { - public static void MyFunction() - { - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public double r; - - public double g; - - public double b; - } - - public static partial class Methods - { - public static MyStruct MyFunction() - { - MyStruct myStruct = new MyStruct(); - - return myStruct; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(int value) - { - return &value; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* value) - { - return *value; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static bool MyFunction(bool value) - { - return !value; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return value{opcode}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return {opcode}value; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index 0b969f31..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,412 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpCompatibleUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""const float[4]"")] float* color); - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""void (*)()"")] IntPtr callback); - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyFunction(); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeAttr ? $@"[NativeTypeName(""MyTemplate<{nativeType}>"")] " : "")}MyTemplate<{expectedManagedType}> myStruct); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTemplate"")] - public MyTemplate a; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport("""", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeNameAttr ? $@"[NativeTypeName(""{nativeType}"")] " : "")}{expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.StdCall, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [SourceLocation(""ClangUnsavedFile.h"", 1, 17)] - public static extern void MyFunction([SourceLocation(""ClangUnsavedFile.h"", 1, 34)] float value); - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionPointerDeclarationTest.cs deleted file mode 100644 index 277d111b..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpCompatibleUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void Callback(); - - public partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public IntPtr _callback; - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate void Callback(); - - public partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public IntPtr _callback; - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void Callback(); - - public partial struct MyStruct - { - [NativeTypeName(""Callback *"")] - public IntPtr _callback; - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs deleted file mode 100644 index a3aa64ce..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/StructDeclarationTest.cs +++ /dev/null @@ -1,2153 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpCompatibleUnix_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[]"")] - public fixed {expectedManagedType} x[1]; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - [NativeTypeName(""unsigned char : 1"")] - public byte o4_b22_1 - { - get - { - return (byte)((_bitfield2 >> 22) & 0x1u); - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b23_1 - { - get - { - return (int)(_bitfield2 << 8) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b24_1 - { - get - { - return (int)(_bitfield2 << 7) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - } - } - } - - public partial struct MyStruct2 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - [NativeBitfield(""o0_b0_24"", offset: 0, length: 24)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - [NativeBitfield(""o4_b0_16"", offset: 0, length: 16)] - [NativeBitfield(""o4_b16_3"", offset: 16, length: 3)] - [NativeBitfield(""o4_b19_3"", offset: 19, length: 3)] - [NativeBitfield(""o4_b22_1"", offset: 22, length: 1)] - [NativeBitfield(""o4_b23_1"", offset: 23, length: 1)] - [NativeBitfield(""o4_b24_1"", offset: 24, length: 1)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - [NativeTypeName(""unsigned char : 1"")] - public byte o4_b22_1 - { - get - { - return (byte)((_bitfield2 >> 22) & 0x1u); - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b23_1 - { - get - { - return (int)(_bitfield2 << 8) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b24_1 - { - get - { - return (int)(_bitfield2 << 7) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - } - } - } - - public partial struct MyStruct2 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - [NativeBitfield(""o8_b0_1"", offset: 0, length: 1)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - [NativeBitfield(""o0_b1_1"", offset: 1, length: 1)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public partial struct MyStruct - { - [NativeTypeName(""decltype(&MyFunction)"")] - public IntPtr _callback; - } - - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - public MyStruct e1; - public MyStruct e2; - - public unsafe ref MyStruct this[int index] - {{ - get - {{ - fixed (MyStruct* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0_0_0_0; - public MyStruct e1_0_0_0; - - public MyStruct e0_0_1_0; - public MyStruct e1_0_1_0; - - public MyStruct e0_0_2_0; - public MyStruct e1_0_2_0; - - public MyStruct e0_0_0_1; - public MyStruct e1_0_0_1; - - public MyStruct e0_0_1_1; - public MyStruct e1_0_1_1; - - public MyStruct e0_0_2_1; - public MyStruct e1_0_2_1; - - public MyStruct e0_0_0_2; - public MyStruct e1_0_0_2; - - public MyStruct e0_0_1_2; - public MyStruct e1_0_1_2; - - public MyStruct e0_0_2_2; - public MyStruct e1_0_2_2; - - public MyStruct e0_0_0_3; - public MyStruct e1_0_0_3; - - public MyStruct e0_0_1_3; - public MyStruct e1_0_1_3; - - public MyStruct e0_0_2_3; - public MyStruct e1_0_2_3; - - public unsafe ref MyStruct this[int index] - {{ - get - {{ - fixed (MyStruct* pThis = &e0_0_0_0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - public MyStruct e1; - public MyStruct e2; - - public unsafe ref MyStruct this[int index] - {{ - get - {{ - fixed (MyStruct* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - public MyStruct e1; - public MyStruct e2; - - public unsafe ref MyStruct this[int index] - {{ - get - {{ - fixed (MyStruct* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public fixed {expectedManagedType} c[3]; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public fixed {expectedManagedType} c[2 * 1 * 3 * 4]; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [NativeTypeName(""MyBuffer"")] - public fixed {expectedManagedType} c[3]; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyStruct1 - {{ - public int x; - }} - - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyStruct2 - {{ - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyStruct1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyStruct2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - [NativeInheritance(""MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - struct - {{ - {nativeType} value1; - - struct - {{ - {nativeType} value; - }}; - }}; - - union - {{ - {nativeType} value2; - }}; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - public unsafe partial struct MyStruct - {{ - public {expectedManagedType} x; - - public {expectedManagedType} y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Struct Anonymous; - - public ref {expectedManagedType} z - {{ - get - {{ - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->z; - }} - }} - }} - - public ref _Anonymous_e__Struct._w_e__Struct w - {{ - get - {{ - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->w; - }} - }} - }} - - public ref {expectedManagedType} value1 - {{ - get - {{ - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) - {{ - return ref pField->value1; - }} - }} - }} - - public ref {expectedManagedType} value - {{ - get - {{ - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous_e__Struct* pField = &Anonymous.Anonymous1.Anonymous) - {{ - return ref pField->value; - }} - }} - }} - - public ref {expectedManagedType} value2 - {{ - get - {{ - fixed (_Anonymous_e__Struct._Anonymous2_e__Union* pField = &Anonymous.Anonymous2) - {{ - return ref pField->value2; - }} - }} - }} - - public ref MyUnion u - {{ - get - {{ - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->u; - }} - }} - }} - - public ref {expectedManagedType} buffer1 - {{ - get - {{ - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->buffer1[0]; - }} - }} - }} - - public ref _Anonymous_e__Struct._buffer2_e__FixedBuffer buffer2 - {{ - get - {{ - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->buffer2; - }} - }} - }} - - public unsafe partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C9"")] - public _w_e__Struct w; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L19_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L29_C9"")] - public _Anonymous2_e__Union Anonymous2; - - public MyUnion u; - - [NativeTypeName(""{nativeType}[4]"")] - public fixed {expectedManagedType} buffer1[4]; - - [NativeTypeName(""MyUnion[4]"")] - public _buffer2_e__FixedBuffer buffer2; - - public partial struct _w_e__Struct - {{ - public {expectedManagedType} value; - }} - - public unsafe partial struct _Anonymous1_e__Struct - {{ - public {expectedManagedType} value1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L23_C13"")] - public _Anonymous_e__Struct Anonymous; - - public partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} value; - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous2_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} value2; - }} - - public partial struct _buffer2_e__FixedBuffer - {{ - public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - public MyUnion e3; - - public unsafe ref MyUnion this[int index] - {{ - get - {{ - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - public int x; - - public int y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Struct Anonymous; - - public ref int z - { - get - { - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->z; - } - } - } - - public ref int w - { - get - { - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) - { - return ref pField->w; - } - } - } - - public int o0_b0_16 - { - get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - public unsafe partial struct _Anonymous_e__Struct - { - public int z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - public partial struct _Anonymous1_e__Struct - { - public int w; - - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public new int Equals; - - public int Dispose; - - public new int GetHashCode; - - public new int GetType; - - public new int MemberwiseClone; - - public new int ReferenceEquals; - - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var usingStatement = "using System.Runtime.InteropServices;\n\n"; - var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; - - if (!Environment.Is64BitProcess) - { - usingStatement = string.Empty; - packing = string.Empty; - } - - var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct1 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} - -{packing} public unsafe partial struct MyStruct2 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - [NativeTypeName(""example_t *"")] - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - public double r; - - public double g; - - public double b; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Struct Anonymous; - - public ref double a - { - get - { - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->a; - } - } - } - - public partial struct _Anonymous_e__Struct - { - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public void MyMethod() - { - } - } - - [NativeTypeName(""struct MyStruct1B : MyStruct1A"")] - public partial struct MyStruct1B - { - public void MyMethod() - { - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - internal partial struct MyStruct1 - { - private int Field1; - - public int Field2; - } - - internal partial struct MyStruct2 - { - private int Field1; - - public int Field2; - } - - public partial struct MyStruct3 - { - private int Field1; - - internal int Field2; - } -} -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"typedef int size_t; - -struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] - public partial struct MyStruct - { - [NativeTypeName(""size_t[2]"")] - public _FixedBuffer_e__FixedBuffer FixedBuffer; - - public partial struct _FixedBuffer_e__FixedBuffer - { - public UIntPtr e0; - public UIntPtr e1; - - public unsafe ref UIntPtr this[int index] - { - get - { - fixed (UIntPtr* pThis = &e0) - { - return ref pThis[index]; - } - } - } - } - } -} -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @"namespace ClangSharp.Test -{ - [SourceLocation(""ClangUnsavedFile.h"", 1, 8)] - public partial struct MyStruct - { - [SourceLocation(""ClangUnsavedFile.h"", 3, 9)] - public int r; - - [SourceLocation(""ClangUnsavedFile.h"", 4, 9)] - public int g; - - [SourceLocation(""ClangUnsavedFile.h"", 5, 9)] - public int b; - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct;"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [NativeTypeName(""struct (anonymous struct at ClangUnsavedFile.h:4:5)[2]"")] - public _MyArray_e__FixedBuffer MyArray; - - public ref int First - { - get - { - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->First; - } - } - } - - public partial struct _Anonymous_e__Struct - { - public int First; - } - - public partial struct _MyArray_e__Struct - { - public int Second; - } - - public partial struct _MyArray_e__FixedBuffer - { - public _MyArray_e__Struct e0; - public _MyArray_e__Struct e1; - - public unsafe ref _MyArray_e__Struct this[int index] - { - get - { - fixed (_MyArray_e__Struct* pThis = &e0) - { - return ref pThis[index]; - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct;"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - public ref int Value1 - { - get - { - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous2_e__Struct* pField = &Anonymous.Anonymous1.Anonymous2) - { - return ref pField->Value1; - } - } - } - - public ref int Value2 - { - get - { - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous3_e__Struct* pField = &Anonymous.Anonymous1.Anonymous3) - { - return ref pField->Value2; - } - } - } - - public unsafe partial struct _Anonymous_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C14"")] - public _Anonymous1_e__Struct Anonymous1; - - public unsafe partial struct _Anonymous1_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C9"")] - public _Anonymous2_e__Struct Anonymous2; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L5_C9"")] - public _Anonymous3_e__Struct Anonymous3; - - public partial struct _Anonymous2_e__Struct - { - public int Value1; - } - - public partial struct _Anonymous3_e__Struct - { - public int Value2; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/UnionDeclarationTest.cs deleted file mode 100644 index 0202a10e..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/UnionDeclarationTest.cs +++ /dev/null @@ -1,1584 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpCompatibleUnix_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - {{ - get - {{ - return _bitfield1 & 0xFFFFFFu; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - }} - }} - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - {{ - get - {{ - return _bitfield2 & 0xFFFFu; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - }} - }} - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - {{ - get - {{ - return (_bitfield2 >> 16) & 0x7u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - }} - }} - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - {{ - get - {{ - return (int)(_bitfield2 << 10) >> 29; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - }} - }} - - [NativeTypeName(""unsigned char : 1"")] - public byte o4_b22_1 - {{ - get - {{ - return (byte)((_bitfield2 >> 22) & 0x1u); - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - }} - }} - - [NativeTypeName(""int : 1"")] - public int o4_b23_1 - {{ - get - {{ - return (int)(_bitfield2 << 8) >> 31; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - }} - }} - - [NativeTypeName(""int : 1"")] - public int o4_b24_1 - {{ - get - {{ - return (int)(_bitfield2 << 7) >> 31; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - get - {{ - return _bitfield1 & 0x1u; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - }} - }} - - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - {{ - get - {{ - return _bitfield2 & 0x1u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion3 - {{ - [FieldOffset(0)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - get - {{ - return _bitfield & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - }} - }} - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - {{ - get - {{ - return (_bitfield >> 1) & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - - public unsafe ref MyUnion this[int index] - {{ - get - {{ - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0_0_0_0; - public MyUnion e1_0_0_0; - - public MyUnion e0_0_1_0; - public MyUnion e1_0_1_0; - - public MyUnion e0_0_2_0; - public MyUnion e1_0_2_0; - - public MyUnion e0_0_0_1; - public MyUnion e1_0_0_1; - - public MyUnion e0_0_1_1; - public MyUnion e1_0_1_1; - - public MyUnion e0_0_2_1; - public MyUnion e1_0_2_1; - - public MyUnion e0_0_0_2; - public MyUnion e1_0_0_2; - - public MyUnion e0_0_1_2; - public MyUnion e1_0_1_2; - - public MyUnion e0_0_2_2; - public MyUnion e1_0_2_2; - - public MyUnion e0_0_0_3; - public MyUnion e1_0_0_3; - - public MyUnion e0_0_1_3; - public MyUnion e1_0_1_3; - - public MyUnion e0_0_2_3; - public MyUnion e1_0_2_3; - - public unsafe ref MyUnion this[int index] - {{ - get - {{ - fixed (MyUnion* pThis = &e0_0_0_0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - - public unsafe ref MyUnion this[int index] - {{ - get - {{ - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - - public unsafe ref MyUnion this[int index] - {{ - get - {{ - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public fixed {expectedManagedType} c[3]; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public fixed {expectedManagedType} c[2 * 1 * 3 * 4]; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public fixed {expectedManagedType} c[3]; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public int x; - }} - - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyUnion1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyUnion2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Union Anonymous; - - public ref {expectedManagedType} a - {{ - get - {{ - fixed (_Anonymous_e__Union* pField = &Anonymous) - {{ - return ref pField->a; - }} - }} - }} - - public ref MyStruct s - {{ - get - {{ - fixed (_Anonymous_e__Union* pField = &Anonymous) - {{ - return ref pField->s; - }} - }} - }} - - public ref {expectedManagedType} buffer - {{ - get - {{ - fixed (_Anonymous_e__Union* pField = &Anonymous) - {{ - return ref pField->buffer[0]; - }} - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} a; - - [FieldOffset(0)] - public MyStruct s; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[4]"")] - public fixed {expectedManagedType} buffer[4]; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion - { - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public int y; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Union Anonymous; - - public ref int z - { - get - { - fixed (_Anonymous_e__Union* pField = &Anonymous) - { - return ref pField->z; - } - } - } - - public ref int w - { - get - { - fixed (_Anonymous_e__Union._Anonymous1_e__Union* pField = &Anonymous.Anonymous1) - { - return ref pField->w; - } - } - } - - public int o0_b0_16 - { - get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public int z; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Union Anonymous1; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous1_e__Union - { - [FieldOffset(0)] - public int w; - - [FieldOffset(0)] - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public new int Equals; - - [FieldOffset(0)] - public int Dispose; - - [FieldOffset(0)] - public new int GetHashCode; - - [FieldOffset(0)] - public new int GetType; - - [FieldOffset(0)] - public new int MemberwiseClone; - - [FieldOffset(0)] - public new int ReferenceEquals; - - [FieldOffset(0)] - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - [NativeTypeName(""example_t *"")] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion - { - [FieldOffset(0)] - public double r; - - [FieldOffset(0)] - public double g; - - [FieldOffset(0)] - public double b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Union Anonymous; - - public ref double a - { - get - { - fixed (_Anonymous_e__Union* pField = &Anonymous) - { - return ref pField->a; - } - } - } - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - } -} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct _MY_UNION - {{ - [FieldOffset(0)] - [NativeTypeName(""long[2]"")] - public _AsArray_e__FixedBuffer AsArray; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C5"")] - public _Anonymous_e__Struct Anonymous; - - public ref IntPtr First - {{ - get - {{ - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->First; - }} - }} - }} - - public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A - {{ - get - {{ - fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) - {{ - return ref pField->A; - }} - }} - }} - - public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B - {{ - get - {{ - fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) - {{ - return ref pField->B; - }} - }} - }} - - public unsafe partial struct _Anonymous_e__Struct - {{ - [NativeTypeName(""long"")] - public IntPtr First; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C9"")] - public _Anonymous_e__Union Anonymous; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L9_C13"")] - public _A_e__Struct A; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C13"")] - public _B_e__Struct B; - - public partial struct _A_e__Struct - {{ - [NativeTypeName(""long"")] - public IntPtr Second; - }} - - public partial struct _B_e__Struct - {{ - [NativeTypeName(""long"")] - public IntPtr Second; - }} - }} - }} - - public partial struct _AsArray_e__FixedBuffer - {{ - public IntPtr e0; - public IntPtr e1; - - public unsafe ref IntPtr this[int index] - {{ - get - {{ - fixed (IntPtr* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs deleted file mode 100644 index e1871e6d..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleUnix/VarDeclarationTest.cs +++ /dev/null @@ -1,411 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpCompatibleUnix_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""{nativeType}"")] - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const GUID"")] - public static readonly Guid IID_IUnknown = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - }} -}} -"; - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 {nativeValue}"")] - public const {expectedManagedType} MyMacro1 = {expectedManagedValue}; - - [NativeTypeName(""#define MyMacro2 MyMacro1"")] - public const {expectedManagedType} MyMacro2 = {expectedManagedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 0 + \\\n1"")] - public const int MyMacro1 = 0 + 1; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] - public static ReadOnlySpan MyMacro1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] - public const string MyMacro1 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; - - [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; - - [NativeTypeName(""const wchar_t *const"")] - public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; - - [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; - - [NativeTypeName(""const wchar_t *const"")] - public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 (long)0x80000000L"")] - public static readonly IntPtr MyMacro1 = unchecked((nint)(0x80000000)); - - [NativeTypeName(""#define MyMacro2 (int)0x80000000"")] - public const int MyMacro2 = unchecked((int)(0x80000000)); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 unsigned(-1)"")] - public const uint MyMacro1 = unchecked((uint)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro3 MyMacro2(3)"")] - public const int MyMacro3 = unchecked((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 ((int*) -1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 reinterpret_cast(-1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const int[2][2]"")] - public static readonly int[][] MyArray = new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"")] - public const int ADDRESS_IN_USE = unchecked((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))); - }} -}} -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs deleted file mode 100644 index 89527a39..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,527 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpCompatibleWindows_CXXMethodDeclarationTest : CXXMethodDeclarationCSharpTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [NativeTypeName(""struct MyStruct : MyTemplate"")] - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern int* DoWork(MyStruct* pThis, int* value = null); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = Environment.Is64BitProcess - ? "?MyVoidMethod@MyStruct@@QEAAXXZ" - : "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(MyStruct* pThis); - - public int MyInt32Method() - {{ - return 0; - }} - - public void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType(MyStruct* pThis, int objA, int objB); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType1(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType2(MyStruct* pThis, int obj); - - public int GetType(int objA, int objB) - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType>((IntPtr)(lpVtbl[0]))(pThis, objA, objB); - }} - }} - - public new int GetType() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType1>((IntPtr)(lpVtbl[1]))(pThis); - }} - }} - - public int GetType(int obj) - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType2>((IntPtr)(lpVtbl[2]))(pThis, obj); - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public Vtbl* lpVtbl; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType(MyStruct* pThis, int objA, int objB); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType1(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType2(MyStruct* pThis, int obj); - - public int GetType(int objA, int objB) - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, objA, objB); - }} - }} - - public new int GetType() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); - }} - }} - - public int GetType(int obj) - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, obj); - }} - }} - - public partial struct Vtbl - {{ - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public new IntPtr GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public IntPtr GetType1; - - [NativeTypeName(""int (int){nativeCallConv}"")] - public IntPtr GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct : MyStruct.Interface - {{ - public Vtbl* lpVtbl; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType(MyStruct* pThis, int objA, int objB); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType1(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _GetType2(MyStruct* pThis, int obj); - - public int GetType(int objA, int objB) - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, objA, objB); - }} - }} - - public new int GetType() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); - }} - }} - - public int GetType(int obj) - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, obj); - }} - }} - - public interface Interface - {{ - int GetType(int objA, int objB); - - int GetType(); - - int GetType(int obj); - }} - - public partial struct Vtbl - {{ - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public new IntPtr GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public IntPtr GetType1; - - [NativeTypeName(""int (int){nativeCallConv}"")] - public IntPtr GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(); - - public static int MyInt32Method() - {{ - return 0; - }} - - public static void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate void _MyVoidMethod(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - [return: NativeTypeName(""signed char"")] - public delegate sbyte _MyInt8Method(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _MyInt32Method(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate void* _MyVoidStarMethod(MyStruct* pThis); - - public void MyVoidMethod() - {{ - fixed (MyStruct* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyVoidMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - }} - - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt8Method>((IntPtr)(lpVtbl[1]))(pThis); - }} - }} - - public int MyInt32Method() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt32Method>((IntPtr)(lpVtbl[2]))(pThis); - }} - }} - - public void* MyVoidStarMethod() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyVoidStarMethod>((IntPtr)(lpVtbl[3]))(pThis); - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate void _MyVoidMethod(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - [return: NativeTypeName(""signed char"")] - public delegate sbyte _MyInt8Method(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate int _MyInt32Method(MyStruct* pThis); - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate void* _MyVoidStarMethod(MyStruct* pThis); - - [VtblIndex(0)] - public void MyVoidMethod() - {{ - fixed (MyStruct* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyVoidMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - }} - - [VtblIndex(1)] - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt8Method>((IntPtr)(lpVtbl[1]))(pThis); - }} - }} - - [VtblIndex(2)] - public int MyInt32Method() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt32Method>((IntPtr)(lpVtbl[2]))(pThis); - }} - }} - - [VtblIndex(3)] - public void* MyVoidStarMethod() - {{ - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyVoidStarMethod>((IntPtr)(lpVtbl[3]))(pThis); - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/DeprecatedToObsoleteTest.cs deleted file mode 100644 index eea3b88d..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,521 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpCompatibleWindows_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - [Obsolete] - MyEnum_Value1, - [Obsolete(""This is obsolete."")] - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum0 - { - MyEnum_Value0, - } - - [Obsolete] - public enum MyEnum1 - { - MyEnum_Value1, - } - - [Obsolete(""This is obsolete."")] - public enum MyEnum2 - { - MyEnum_Value2, - } - - public enum MyEnum3 - { - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable0 = 0; - - [Obsolete] - public static {expectedManagedType} MyVariable1 = 0; - - [Obsolete(""This is obsolete."")] - public static {expectedManagedType} MyVariable2 = 0; - - public static {expectedManagedType} MyVariable3 = 0; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction0() - { - } - - [Obsolete] - public static void MyFunction1() - { - } - - [Obsolete(""This is obsolete."")] - public static void MyFunction2() - { - } - - public static void MyFunction3() - { - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public int MyFunction0() - {{ - return 0; - }} - - [Obsolete] - public int MyFunction1() - {{ - return 0; - }} - - [Obsolete(""This is obsolete."")] - public int MyFunction2() - {{ - return 0; - }} - - public int MyFunction3() - {{ - return 0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void Callback0(); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - [Obsolete] - public delegate void Callback1(); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - [Obsolete(""This is obsolete."")] - public delegate void Callback2(); - - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void Callback3(); - - public partial struct MyStruct0 - { - [NativeTypeName(""Callback0"")] - public IntPtr _callback; - } - - public partial struct MyStruct1 - { - [NativeTypeName(""Callback1"")] - [Obsolete] - public IntPtr _callback; - } - - public partial struct MyStruct2 - { - [NativeTypeName(""Callback2"")] - [Obsolete(""This is obsolete."")] - public IntPtr _callback; - } - - public partial struct MyStruct3 - { - [NativeTypeName(""Callback3"")] - public IntPtr _callback; - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction0(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete] - public static extern void MyFunction1(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete(""This is obsolete."")] - public static extern void MyFunction2(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction3(); - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/DigitsSeparatorTest.cs deleted file mode 100644 index 0301621b..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/DigitsSeparatorTest.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.CSharpCompatibleWindows; - -[Platform("win")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyClass - {{ - [NativeTypeName(""const {type}"")] - private const {type} x = {expectedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs deleted file mode 100644 index 2b345d91..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/EnumDeclarationTest.cs +++ /dev/null @@ -1,611 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpCompatibleWindows_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - [NativeTypeName(""{nativeType}"")] - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum1 : int -{ - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, -} MyEnum1; - -namespace Namespace1 -{ - namespace Namespace2 - { - typedef enum _MyEnum2 : int - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } MyEnum2; - - typedef enum _MyEnum3 : int - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } MyEnum3; - - typedef enum _MyEnum4 : int - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } MyEnum4; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, - } - - public enum MyEnum2 - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } - - public enum MyEnum3 - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } - - public enum MyEnum4 - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } -} -"; - - var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - [Flags] - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = 1, - } -} -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using System; -using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0 = (int)(MyEnum)(10), - MyEnum_Value1 = (int)(MyEnum)(MyEnum_Value0), - MyEnum_Value2 = ((int)(MyEnum)(10)) + MyEnum_Value1, - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0 = 10, - } - - public enum MyEnum2 - { - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (int)(MyEnum1)(10), - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = unchecked((int)(0x80000000)), - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, - } -} -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum1 : uint - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.Methods; - -namespace ClangSharp.Test -{ - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } - - public static partial class Methods - { - public const int MyEnum1_Value1 = 1; - } -} -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public const int MyEnum1_Value1 = 1; - - [NativeTypeName(""const int"")] - public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; - } -} -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index 6fb6fe87..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,1795 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpCompatibleWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* pData, int index) - { - return pData[index]; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(bool x, bool y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - break; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction() - { - } - - public static void MyFunction() - { - MyCalledFunction(); - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction(int x, int y) - { - } - - public static void MyFunction() - { - MyCalledFunction(0, 1); - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 2: - case 3: - { - return 5; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } - - public static partial class Methods - { - public static int MyFunction(MyEnum x) - { - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - return condition ? lhs : rhs; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - continue; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction([NativeTypeName(""const void *"")] void* input) - { - return input; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStructA - {{ - public void** lpVtbl; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate void _MyMethod(MyStructA* pThis); - - public void MyMethod() - {{ - fixed (MyStructA* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - }} - }} - - [NativeTypeName(""struct MyStructB : MyStructA"")] - public unsafe partial struct MyStructB - {{ - public void** lpVtbl; - - [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - public delegate void _MyMethod(MyStructB* pThis); - - public void MyMethod() - {{ - fixed (MyStructB* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - }} - }} - - public static unsafe partial class Methods - {{ - public static MyStructB* MyFunction(MyStructA* input) - {{ - return (MyStructB*)(input); - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - int x = 0; - int y = 1, z = 2; - - return x + y + z; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - - return rhs; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition1, int a, int b, bool condition2, int c) - { - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public float x; - - public float y; - - public float z; - - public float w; - } - - public static partial class Methods - { - public static MyStruct MyFunction1() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - } - - public static MyStruct MyFunction2() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static int MyFunction1(MyStruct instance) - { - return instance.value; - } - - public static int MyFunction2(MyStruct* instance) - { - return instance->value; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static bool MyFunction([NativeTypeName(""const MyStruct &"")] MyStruct* lhs, [NativeTypeName(""const MyStruct &"")] MyStruct* rhs) - { - return lhs->value == rhs->value; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction() - { - return null; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static double MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static float MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - return; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion - { - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - public ref int a - { - get - { - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->a; - } - } - } - - public partial struct _Anonymous_e__Struct - { - public int a; - } - } - - public static partial class Methods - { - public static void MyFunction() - { - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public double r; - - public double g; - - public double b; - } - - public static partial class Methods - { - public static MyStruct MyFunction() - { - MyStruct myStruct = new MyStruct(); - - return myStruct; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(int value) - { - return &value; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* value) - { - return *value; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static bool MyFunction(bool value) - { - return !value; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return value{opcode}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return {opcode}value; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index 5b04ad84..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,429 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpCompatibleWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""const float[4]"")] float* color); - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""void (*)()"")] IntPtr callback); - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyFunction(); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeAttr ? $@"[NativeTypeName(""MyTemplate<{nativeType}>"")] " : "")}MyTemplate<{expectedManagedType}> myStruct); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTemplate"")] - public MyTemplate a; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport("""", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeNameAttr ? $@"[NativeTypeName(""{nativeType}"")] " : "")}{expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.StdCall, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [SourceLocation(""ClangUnsavedFile.h"", 1, 17)] - public static extern void MyFunction([SourceLocation(""ClangUnsavedFile.h"", 1, 34)] float value); - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(int value, ...);"; - - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(int value, __arglist); - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionPointerDeclarationTest.cs deleted file mode 100644 index 9a27a03b..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpCompatibleWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void Callback(); - - public partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public IntPtr _callback; - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - public delegate void Callback(); - - public partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public IntPtr _callback; - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void Callback(); - - public partial struct MyStruct - { - [NativeTypeName(""Callback *"")] - public IntPtr _callback; - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs deleted file mode 100644 index f3b68211..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/StructDeclarationTest.cs +++ /dev/null @@ -1,2159 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpCompatibleWindows_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[]"")] - public fixed {expectedManagedType} x[1]; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - public byte _bitfield3; - - [NativeTypeName(""unsigned char : 1"")] - public byte o8_b0_1 - { - get - { - return (byte)(_bitfield3 & 0x1u); - } - - set - { - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - } - } - - public int _bitfield4; - - [NativeTypeName(""int : 1"")] - public int o12_b0_1 - { - get - { - return (_bitfield4 << 31) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - } - } - - [NativeTypeName(""int : 1"")] - public int o12_b1_1 - { - get - { - return (_bitfield4 << 30) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - } - } - } - - public partial struct MyStruct2 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - [NativeBitfield(""o0_b0_24"", offset: 0, length: 24)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - [NativeBitfield(""o4_b0_16"", offset: 0, length: 16)] - [NativeBitfield(""o4_b16_3"", offset: 16, length: 3)] - [NativeBitfield(""o4_b19_3"", offset: 19, length: 3)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - [NativeBitfield(""o8_b0_1"", offset: 0, length: 1)] - public byte _bitfield3; - - [NativeTypeName(""unsigned char : 1"")] - public byte o8_b0_1 - { - get - { - return (byte)(_bitfield3 & 0x1u); - } - - set - { - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - } - } - - [NativeBitfield(""o12_b0_1"", offset: 0, length: 1)] - [NativeBitfield(""o12_b1_1"", offset: 1, length: 1)] - public int _bitfield4; - - [NativeTypeName(""int : 1"")] - public int o12_b0_1 - { - get - { - return (_bitfield4 << 31) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - } - } - - [NativeTypeName(""int : 1"")] - public int o12_b1_1 - { - get - { - return (_bitfield4 << 30) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - } - } - } - - public partial struct MyStruct2 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - [NativeBitfield(""o8_b0_1"", offset: 0, length: 1)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - [NativeBitfield(""o0_b1_1"", offset: 1, length: 1)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public partial struct MyStruct - { - [NativeTypeName(""decltype(&MyFunction)"")] - public IntPtr _callback; - } - - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - public MyStruct e1; - public MyStruct e2; - - public unsafe ref MyStruct this[int index] - {{ - get - {{ - fixed (MyStruct* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0_0_0_0; - public MyStruct e1_0_0_0; - - public MyStruct e0_0_1_0; - public MyStruct e1_0_1_0; - - public MyStruct e0_0_2_0; - public MyStruct e1_0_2_0; - - public MyStruct e0_0_0_1; - public MyStruct e1_0_0_1; - - public MyStruct e0_0_1_1; - public MyStruct e1_0_1_1; - - public MyStruct e0_0_2_1; - public MyStruct e1_0_2_1; - - public MyStruct e0_0_0_2; - public MyStruct e1_0_0_2; - - public MyStruct e0_0_1_2; - public MyStruct e1_0_1_2; - - public MyStruct e0_0_2_2; - public MyStruct e1_0_2_2; - - public MyStruct e0_0_0_3; - public MyStruct e1_0_0_3; - - public MyStruct e0_0_1_3; - public MyStruct e1_0_1_3; - - public MyStruct e0_0_2_3; - public MyStruct e1_0_2_3; - - public unsafe ref MyStruct this[int index] - {{ - get - {{ - fixed (MyStruct* pThis = &e0_0_0_0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - public MyStruct e1; - public MyStruct e2; - - public unsafe ref MyStruct this[int index] - {{ - get - {{ - fixed (MyStruct* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - public MyStruct e1; - public MyStruct e2; - - public unsafe ref MyStruct this[int index] - {{ - get - {{ - fixed (MyStruct* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public fixed {expectedManagedType} c[3]; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public fixed {expectedManagedType} c[2 * 1 * 3 * 4]; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [NativeTypeName(""MyBuffer"")] - public fixed {expectedManagedType} c[3]; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyStruct1 - {{ - public int x; - }} - - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyStruct2 - {{ - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyStruct1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyStruct2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - [NativeInheritance(""MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - struct - {{ - {nativeType} value1; - - struct - {{ - {nativeType} value; - }}; - }}; - - union - {{ - {nativeType} value2; - }}; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - public unsafe partial struct MyStruct - {{ - public {expectedManagedType} x; - - public {expectedManagedType} y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Struct Anonymous; - - public ref {expectedManagedType} z - {{ - get - {{ - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->z; - }} - }} - }} - - public ref _Anonymous_e__Struct._w_e__Struct w - {{ - get - {{ - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->w; - }} - }} - }} - - public ref {expectedManagedType} value1 - {{ - get - {{ - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) - {{ - return ref pField->value1; - }} - }} - }} - - public ref {expectedManagedType} value - {{ - get - {{ - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous_e__Struct* pField = &Anonymous.Anonymous1.Anonymous) - {{ - return ref pField->value; - }} - }} - }} - - public ref {expectedManagedType} value2 - {{ - get - {{ - fixed (_Anonymous_e__Struct._Anonymous2_e__Union* pField = &Anonymous.Anonymous2) - {{ - return ref pField->value2; - }} - }} - }} - - public ref MyUnion u - {{ - get - {{ - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->u; - }} - }} - }} - - public ref {expectedManagedType} buffer1 - {{ - get - {{ - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->buffer1[0]; - }} - }} - }} - - public ref _Anonymous_e__Struct._buffer2_e__FixedBuffer buffer2 - {{ - get - {{ - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->buffer2; - }} - }} - }} - - public unsafe partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C9"")] - public _w_e__Struct w; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L19_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L29_C9"")] - public _Anonymous2_e__Union Anonymous2; - - public MyUnion u; - - [NativeTypeName(""{nativeType}[4]"")] - public fixed {expectedManagedType} buffer1[4]; - - [NativeTypeName(""MyUnion[4]"")] - public _buffer2_e__FixedBuffer buffer2; - - public partial struct _w_e__Struct - {{ - public {expectedManagedType} value; - }} - - public unsafe partial struct _Anonymous1_e__Struct - {{ - public {expectedManagedType} value1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L23_C13"")] - public _Anonymous_e__Struct Anonymous; - - public partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} value; - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous2_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} value2; - }} - - public partial struct _buffer2_e__FixedBuffer - {{ - public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - public MyUnion e3; - - public unsafe ref MyUnion this[int index] - {{ - get - {{ - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - public int x; - - public int y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Struct Anonymous; - - public ref int z - { - get - { - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->z; - } - } - } - - public ref int w - { - get - { - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) - { - return ref pField->w; - } - } - } - - public int o0_b0_16 - { - get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - public unsafe partial struct _Anonymous_e__Struct - { - public int z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - public partial struct _Anonymous1_e__Struct - { - public int w; - - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public new int Equals; - - public int Dispose; - - public new int GetHashCode; - - public new int GetType; - - public new int MemberwiseClone; - - public new int ReferenceEquals; - - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var usingStatement = "using System.Runtime.InteropServices;\n\n"; - var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; - - if (!Environment.Is64BitProcess) - { - usingStatement = string.Empty; - packing = string.Empty; - } - - var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct1 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} - -{packing} public unsafe partial struct MyStruct2 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - [NativeTypeName(""example_t *"")] - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - public double r; - - public double g; - - public double b; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Struct Anonymous; - - public ref double a - { - get - { - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->a; - } - } - } - - public partial struct _Anonymous_e__Struct - { - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public void MyMethod() - { - } - } - - [NativeTypeName(""struct MyStruct1B : MyStruct1A"")] - public partial struct MyStruct1B - { - public void MyMethod() - { - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - internal partial struct MyStruct1 - { - private int Field1; - - public int Field2; - } - - internal partial struct MyStruct2 - { - private int Field1; - - public int Field2; - } - - public partial struct MyStruct3 - { - private int Field1; - - internal int Field2; - } -} -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] - public partial struct MyStruct - { - [NativeTypeName(""size_t[2]"")] - public _FixedBuffer_e__FixedBuffer FixedBuffer; - - public partial struct _FixedBuffer_e__FixedBuffer - { - public UIntPtr e0; - public UIntPtr e1; - - public unsafe ref UIntPtr this[int index] - { - get - { - fixed (UIntPtr* pThis = &e0) - { - return ref pThis[index]; - } - } - } - } - } -} -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @"namespace ClangSharp.Test -{ - [SourceLocation(""ClangUnsavedFile.h"", 1, 8)] - public partial struct MyStruct - { - [SourceLocation(""ClangUnsavedFile.h"", 3, 9)] - public int r; - - [SourceLocation(""ClangUnsavedFile.h"", 4, 9)] - public int g; - - [SourceLocation(""ClangUnsavedFile.h"", 5, 9)] - public int b; - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct;"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [NativeTypeName(""struct (anonymous struct at ClangUnsavedFile.h:4:5)[2]"")] - public _MyArray_e__FixedBuffer MyArray; - - public ref int First - { - get - { - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->First; - } - } - } - - public partial struct _Anonymous_e__Struct - { - public int First; - } - - public partial struct _MyArray_e__Struct - { - public int Second; - } - - public partial struct _MyArray_e__FixedBuffer - { - public _MyArray_e__Struct e0; - public _MyArray_e__Struct e1; - - public unsafe ref _MyArray_e__Struct this[int index] - { - get - { - fixed (_MyArray_e__Struct* pThis = &e0) - { - return ref pThis[index]; - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct;"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - public ref int Value1 - { - get - { - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous2_e__Struct* pField = &Anonymous.Anonymous1.Anonymous2) - { - return ref pField->Value1; - } - } - } - - public ref int Value2 - { - get - { - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous3_e__Struct* pField = &Anonymous.Anonymous1.Anonymous3) - { - return ref pField->Value2; - } - } - } - - public unsafe partial struct _Anonymous_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C14"")] - public _Anonymous1_e__Struct Anonymous1; - - public unsafe partial struct _Anonymous1_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C9"")] - public _Anonymous2_e__Struct Anonymous2; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L5_C9"")] - public _Anonymous3_e__Struct Anonymous3; - - public partial struct _Anonymous2_e__Struct - { - public int Value1; - } - - public partial struct _Anonymous3_e__Struct - { - public int Value2; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/UnionDeclarationTest.cs deleted file mode 100644 index 372e97f2..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/UnionDeclarationTest.cs +++ /dev/null @@ -1,1573 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpCompatibleWindows_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - {{ - get - {{ - return _bitfield1 & 0xFFFFFFu; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - }} - }} - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - {{ - get - {{ - return _bitfield2 & 0xFFFFu; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - }} - }} - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - {{ - get - {{ - return (_bitfield2 >> 16) & 0x7u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - }} - }} - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - {{ - get - {{ - return (int)(_bitfield2 << 10) >> 29; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - }} - }} - - [FieldOffset(0)] - public byte _bitfield3; - - [NativeTypeName(""unsigned char : 1"")] - public byte o8_b0_1 - {{ - get - {{ - return (byte)(_bitfield3 & 0x1u); - }} - - set - {{ - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - }} - }} - - [FieldOffset(0)] - public int _bitfield4; - - [NativeTypeName(""int : 1"")] - public int o12_b0_1 - {{ - get - {{ - return (_bitfield4 << 31) >> 31; - }} - - set - {{ - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - }} - }} - - [NativeTypeName(""int : 1"")] - public int o12_b1_1 - {{ - get - {{ - return (_bitfield4 << 30) >> 31; - }} - - set - {{ - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - get - {{ - return _bitfield1 & 0x1u; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - }} - }} - - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - {{ - get - {{ - return _bitfield2 & 0x1u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion3 - {{ - [FieldOffset(0)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - get - {{ - return _bitfield & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - }} - }} - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - {{ - get - {{ - return (_bitfield >> 1) & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - - public unsafe ref MyUnion this[int index] - {{ - get - {{ - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0_0_0_0; - public MyUnion e1_0_0_0; - - public MyUnion e0_0_1_0; - public MyUnion e1_0_1_0; - - public MyUnion e0_0_2_0; - public MyUnion e1_0_2_0; - - public MyUnion e0_0_0_1; - public MyUnion e1_0_0_1; - - public MyUnion e0_0_1_1; - public MyUnion e1_0_1_1; - - public MyUnion e0_0_2_1; - public MyUnion e1_0_2_1; - - public MyUnion e0_0_0_2; - public MyUnion e1_0_0_2; - - public MyUnion e0_0_1_2; - public MyUnion e1_0_1_2; - - public MyUnion e0_0_2_2; - public MyUnion e1_0_2_2; - - public MyUnion e0_0_0_3; - public MyUnion e1_0_0_3; - - public MyUnion e0_0_1_3; - public MyUnion e1_0_1_3; - - public MyUnion e0_0_2_3; - public MyUnion e1_0_2_3; - - public unsafe ref MyUnion this[int index] - {{ - get - {{ - fixed (MyUnion* pThis = &e0_0_0_0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - - public unsafe ref MyUnion this[int index] - {{ - get - {{ - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - public MyUnion e1; - public MyUnion e2; - - public unsafe ref MyUnion this[int index] - {{ - get - {{ - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public fixed {expectedManagedType} c[3]; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public fixed {expectedManagedType} c[2 * 1 * 3 * 4]; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public fixed {expectedManagedType} c[3]; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public int x; - }} - - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyUnion1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyUnion2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Union Anonymous; - - public ref {expectedManagedType} a - {{ - get - {{ - fixed (_Anonymous_e__Union* pField = &Anonymous) - {{ - return ref pField->a; - }} - }} - }} - - public ref MyStruct s - {{ - get - {{ - fixed (_Anonymous_e__Union* pField = &Anonymous) - {{ - return ref pField->s; - }} - }} - }} - - public ref {expectedManagedType} buffer - {{ - get - {{ - fixed (_Anonymous_e__Union* pField = &Anonymous) - {{ - return ref pField->buffer[0]; - }} - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} a; - - [FieldOffset(0)] - public MyStruct s; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[4]"")] - public fixed {expectedManagedType} buffer[4]; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion - { - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public int y; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Union Anonymous; - - public ref int z - { - get - { - fixed (_Anonymous_e__Union* pField = &Anonymous) - { - return ref pField->z; - } - } - } - - public ref int w - { - get - { - fixed (_Anonymous_e__Union._Anonymous1_e__Union* pField = &Anonymous.Anonymous1) - { - return ref pField->w; - } - } - } - - public int o0_b0_16 - { - get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public int z; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Union Anonymous1; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous1_e__Union - { - [FieldOffset(0)] - public int w; - - [FieldOffset(0)] - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public new int Equals; - - [FieldOffset(0)] - public int Dispose; - - [FieldOffset(0)] - public new int GetHashCode; - - [FieldOffset(0)] - public new int GetType; - - [FieldOffset(0)] - public new int MemberwiseClone; - - [FieldOffset(0)] - public new int ReferenceEquals; - - [FieldOffset(0)] - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - [NativeTypeName(""example_t *"")] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct MyUnion - { - [FieldOffset(0)] - public double r; - - [FieldOffset(0)] - public double g; - - [FieldOffset(0)] - public double b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Union Anonymous; - - public ref double a - { - get - { - fixed (_Anonymous_e__Union* pField = &Anonymous) - { - return ref pField->a; - } - } - } - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct _MY_UNION - {{ - [FieldOffset(0)] - [NativeTypeName(""long[2]"")] - public fixed int AsArray[2]; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C5"")] - public _Anonymous_e__Struct Anonymous; - - public ref int First - {{ - get - {{ - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->First; - }} - }} - }} - - public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A - {{ - get - {{ - fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) - {{ - return ref pField->A; - }} - }} - }} - - public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B - {{ - get - {{ - fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) - {{ - return ref pField->B; - }} - }} - }} - - public unsafe partial struct _Anonymous_e__Struct - {{ - [NativeTypeName(""long"")] - public int First; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C9"")] - public _Anonymous_e__Union Anonymous; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L9_C13"")] - public _A_e__Struct A; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C13"")] - public _B_e__Struct B; - - public partial struct _A_e__Struct - {{ - [NativeTypeName(""long"")] - public int Second; - }} - - public partial struct _B_e__Struct - {{ - [NativeTypeName(""long"")] - public int Second; - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs deleted file mode 100644 index 33db4311..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpCompatibleWindows/VarDeclarationTest.cs +++ /dev/null @@ -1,408 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpCompatibleWindows_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""{nativeType}"")] - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const GUID"")] - public static readonly Guid IID_IUnknown = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - }} -}} -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 {nativeValue}"")] - public const {expectedManagedType} MyMacro1 = {expectedManagedValue}; - - [NativeTypeName(""#define MyMacro2 MyMacro1"")] - public const {expectedManagedType} MyMacro2 = {expectedManagedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 0 + \\\n1"")] - public const int MyMacro1 = 0 + 1; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] - public static ReadOnlySpan MyMacro1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] - public const string MyMacro1 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public const string MyConst1 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public const string MyConst1 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 (long)0x80000000L"")] - public const int MyMacro1 = unchecked((int)(0x80000000)); - - [NativeTypeName(""#define MyMacro2 (int)0x80000000"")] - public const int MyMacro2 = unchecked((int)(0x80000000)); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 unsigned(-1)"")] - public const uint MyMacro1 = unchecked((uint)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro3 MyMacro2(3)"")] - public const int MyMacro3 = unchecked((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 ((int*) -1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 reinterpret_cast(-1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const int[2][2]"")] - public static readonly int[][] MyArray = new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"")] - public const int ADDRESS_IN_USE = unchecked((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))); - }} -}} -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/CXXMethodDeclarationTest.cs deleted file mode 100644 index d06fc90a..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,419 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpDefaultUnix_CXXMethodDeclarationTest : CXXMethodDeclarationCSharpTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [NativeTypeName(""struct MyStruct : MyTemplate"")] - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern int* DoWork(MyStruct* pThis, int* value = null); - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = Environment.Is64BitProcess - ? "?MyVoidMethod@MyStruct@@QEAAXXZ" - : "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(MyStruct* pThis); - - public int MyInt32Method() - {{ - return 0; - }} - - public void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - public int GetType(int obj) - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public new int GetType() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int objA, int objB) - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public Vtbl* lpVtbl; - - public int GetType(int obj) - {{ - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public new int GetType() - {{ - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int objA, int objB) - {{ - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public partial struct Vtbl - {{ - [NativeTypeName(""int (int){nativeCallConv}"")] - public new delegate* unmanaged[Thiscall] GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType1; - - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct : MyStruct.Interface - {{ - public Vtbl* lpVtbl; - - public int GetType(int obj) - {{ - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public new int GetType() - {{ - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int objA, int objB) - {{ - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public interface Interface - {{ - int GetType(int obj); - - int GetType(); - - int GetType(int objA, int objB); - }} - - public partial struct Vtbl - where TSelf : unmanaged, Interface - {{ - [NativeTypeName(""int (int){nativeCallConv}"")] - public new delegate* unmanaged[Thiscall] GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType1; - - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(); - - public static int MyInt32Method() - {{ - return 0; - }} - - public static void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - public void MyVoidMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int MyInt32Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public void* MyVoidStarMethod() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - [VtblIndex(0)] - public void MyVoidMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(1)] - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(2)] - public int MyInt32Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(3)] - public void* MyVoidStarMethod() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/DeprecatedToObsoleteTest.cs deleted file mode 100644 index cfccc233..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,506 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpDefaultUnix_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - [Obsolete] - MyEnum_Value1, - [Obsolete(""This is obsolete."")] - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum0 - { - MyEnum_Value0, - } - - [Obsolete] - public enum MyEnum1 - { - MyEnum_Value1, - } - - [Obsolete(""This is obsolete."")] - public enum MyEnum2 - { - MyEnum_Value2, - } - - public enum MyEnum3 - { - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable0 = 0; - - [Obsolete] - public static {expectedManagedType} MyVariable1 = 0; - - [Obsolete(""This is obsolete."")] - public static {expectedManagedType} MyVariable2 = 0; - - public static {expectedManagedType} MyVariable3 = 0; - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction0() - { - } - - [Obsolete] - public static void MyFunction1() - { - } - - [Obsolete(""This is obsolete."")] - public static void MyFunction2() - { - } - - public static void MyFunction3() - { - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public int MyFunction0() - {{ - return 0; - }} - - [Obsolete] - public int MyFunction1() - {{ - return 0; - }} - - [Obsolete(""This is obsolete."")] - public int MyFunction2() - {{ - return 0; - }} - - public int MyFunction3() - {{ - return 0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct0 - { - [NativeTypeName(""Callback0"")] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct1 - { - [NativeTypeName(""Callback1"")] - [Obsolete] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct2 - { - [NativeTypeName(""Callback2"")] - [Obsolete(""This is obsolete."")] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct3 - { - [NativeTypeName(""Callback3"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction0(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete] - public static extern void MyFunction1(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete(""This is obsolete."")] - public static extern void MyFunction2(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction3(); - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/DigitsSeparatorTest.cs deleted file mode 100644 index 91a4ab4f..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/DigitsSeparatorTest.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.CSharpDefaultUnix; - -[Platform("unix")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyClass - {{ - [NativeTypeName(""const {type}"")] - private const {type} x = {expectedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/EnumDeclarationTest.cs deleted file mode 100644 index 422a15b0..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/EnumDeclarationTest.cs +++ /dev/null @@ -1,611 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpDefaultUnix_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - [NativeTypeName(""{nativeType}"")] - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum1 : int -{ - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, -} MyEnum1; - -namespace Namespace1 -{ - namespace Namespace2 - { - typedef enum _MyEnum2 : int - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } MyEnum2; - - typedef enum _MyEnum3 : int - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } MyEnum3; - - typedef enum _MyEnum4 : int - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } MyEnum4; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, - } - - public enum MyEnum2 - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } - - public enum MyEnum3 - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } - - public enum MyEnum4 - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } -} -"; - - var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - [Flags] - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = 1, - } -} -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using System; -using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0 = (int)(MyEnum)(10), - MyEnum_Value1 = (int)(MyEnum)(MyEnum_Value0), - MyEnum_Value2 = ((int)(MyEnum)(10)) + MyEnum_Value1, - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0 = 10, - } - - public enum MyEnum2 - { - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (int)(MyEnum1)(10), - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = unchecked((int)(0x80000000)), - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, - } -} -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum1 : uint - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.Methods; - -namespace ClangSharp.Test -{ - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } - - public static partial class Methods - { - public const uint MyEnum1_Value1 = 1; - } -} -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public const uint MyEnum1_Value1 = 1; - - [NativeTypeName(""const int"")] - public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; - } -} -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index 0f287186..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,1781 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpDefaultUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* pData, int index) - { - return pData[index]; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(bool x, bool y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - break; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction() - { - } - - public static void MyFunction() - { - MyCalledFunction(); - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction(int x, int y) - { - } - - public static void MyFunction() - { - MyCalledFunction(0, 1); - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 2: - case 3: - { - return 5; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } - - public static partial class Methods - { - public static int MyFunction(MyEnum x) - { - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - return condition ? lhs : rhs; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - continue; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction([NativeTypeName(""const void *"")] void* input) - { - return input; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStructA - {{ - public void** lpVtbl; - - public void MyMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); - }} - }} - - [NativeTypeName(""struct MyStructB : MyStructA"")] - public unsafe partial struct MyStructB - {{ - public void** lpVtbl; - - public void MyMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); - }} - }} - - public static unsafe partial class Methods - {{ - public static MyStructB* MyFunction(MyStructA* input) - {{ - return (MyStructB*)(input); - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - int x = 0; - int y = 1, z = 2; - - return x + y + z; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - - return rhs; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition1, int a, int b, bool condition2, int c) - { - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public float x; - - public float y; - - public float z; - - public float w; - } - - public static partial class Methods - { - public static MyStruct MyFunction1() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - } - - public static MyStruct MyFunction2() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static int MyFunction1(MyStruct instance) - { - return instance.value; - } - - public static int MyFunction2(MyStruct* instance) - { - return instance->value; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static bool MyFunction([NativeTypeName(""const MyStruct &"")] MyStruct* lhs, [NativeTypeName(""const MyStruct &"")] MyStruct* rhs) - { - return lhs->value == rhs->value; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction() - { - return null; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static double MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static float MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - return; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int a - { - get - { - return ref Anonymous.a; - } - } - - public partial struct _Anonymous_e__Struct - { - public int a; - } - } - - public static partial class Methods - { - public static void MyFunction() - { - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public double r; - - public double g; - - public double b; - } - - public static partial class Methods - { - public static MyStruct MyFunction() - { - MyStruct myStruct = new MyStruct(); - - return myStruct; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(int value) - { - return &value; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* value) - { - return *value; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static bool MyFunction(bool value) - { - return !value; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return value{opcode}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return {opcode}value; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index e738ed82..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,411 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpDefaultUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""const float[4]"")] float* color); - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""void (*)()"")] delegate* unmanaged[Cdecl] callback); - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyFunction(); - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeAttr ? $@"[NativeTypeName(""MyTemplate<{nativeType}>"")] " : "")}MyTemplate<{expectedManagedType}> myStruct); - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTemplate"")] - public MyTemplate a; - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport("""", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeNameAttr ? $@"[NativeTypeName(""{nativeType}"")] " : "")}{expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.StdCall, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [SourceLocation(""ClangUnsavedFile.h"", 1, 17)] - public static extern void MyFunction([SourceLocation(""ClangUnsavedFile.h"", 1, 34)] float value); - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionPointerDeclarationTest.cs deleted file mode 100644 index c73ce7a2..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpDefaultUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public delegate* unmanaged[Stdcall] _callback; - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback *"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/StructDeclarationTest.cs deleted file mode 100644 index 45bfaec5..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/StructDeclarationTest.cs +++ /dev/null @@ -1,2082 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpDefaultUnix_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[]"")] - public _x_e__FixedBuffer x; - - public partial struct _x_e__FixedBuffer - {{ - public {expectedManagedType} e0; - - [UnscopedRef] - public ref {expectedManagedType} this[int index] - {{ - get - {{ - return ref Unsafe.Add(ref e0, index); - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - readonly get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - readonly get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - readonly get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - readonly get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - [NativeTypeName(""unsigned char : 1"")] - public byte o4_b22_1 - { - readonly get - { - return (byte)((_bitfield2 >> 22) & 0x1u); - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b23_1 - { - readonly get - { - return (int)(_bitfield2 << 8) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b24_1 - { - readonly get - { - return (int)(_bitfield2 << 7) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - } - } - } - - public partial struct MyStruct2 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - readonly get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - readonly get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - [NativeBitfield(""o0_b0_24"", offset: 0, length: 24)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - readonly get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - [NativeBitfield(""o4_b0_16"", offset: 0, length: 16)] - [NativeBitfield(""o4_b16_3"", offset: 16, length: 3)] - [NativeBitfield(""o4_b19_3"", offset: 19, length: 3)] - [NativeBitfield(""o4_b22_1"", offset: 22, length: 1)] - [NativeBitfield(""o4_b23_1"", offset: 23, length: 1)] - [NativeBitfield(""o4_b24_1"", offset: 24, length: 1)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - readonly get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - readonly get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - readonly get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - [NativeTypeName(""unsigned char : 1"")] - public byte o4_b22_1 - { - readonly get - { - return (byte)((_bitfield2 >> 22) & 0x1u); - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b23_1 - { - readonly get - { - return (int)(_bitfield2 << 8) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b24_1 - { - readonly get - { - return (int)(_bitfield2 << 7) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - } - } - } - - public partial struct MyStruct2 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - [NativeBitfield(""o8_b0_1"", offset: 0, length: 1)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - readonly get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - [NativeBitfield(""o0_b1_1"", offset: 1, length: 1)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - readonly get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""decltype(&MyFunction)"")] - public delegate* unmanaged[Cdecl] _callback; - } - - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyStruct1 - {{ - public int x; - }} - - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyStruct2 - {{ - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyStruct1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyStruct2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - [NativeInheritance(""MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - struct - {{ - {nativeType} value1; - - struct - {{ - {nativeType} value; - }}; - }}; - - union - {{ - {nativeType} value2; - }}; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - public partial struct MyStruct - {{ - public {expectedManagedType} x; - - public {expectedManagedType} y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref {expectedManagedType} z - {{ - get - {{ - return ref Anonymous.z; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._w_e__Struct w - {{ - get - {{ - return ref Anonymous.w; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value1 - {{ - get - {{ - return ref Anonymous.Anonymous1.value1; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value - {{ - get - {{ - return ref Anonymous.Anonymous1.Anonymous.value; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value2 - {{ - get - {{ - return ref Anonymous.Anonymous2.value2; - }} - }} - - [UnscopedRef] - public ref MyUnion u - {{ - get - {{ - return ref Anonymous.u; - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> buffer1 - {{ - get - {{ - return Anonymous.buffer1; - }} - }} - - [UnscopedRef] - public Span buffer2 - {{ - get - {{ - return Anonymous.buffer2; - }} - }} - - public partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C9"")] - public _w_e__Struct w; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L19_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L29_C9"")] - public _Anonymous2_e__Union Anonymous2; - - public MyUnion u; - - [NativeTypeName(""{nativeType}[4]"")] - public _buffer1_e__FixedBuffer buffer1; - - [NativeTypeName(""MyUnion[4]"")] - public _buffer2_e__FixedBuffer buffer2; - - public partial struct _w_e__Struct - {{ - public {expectedManagedType} value; - }} - - public partial struct _Anonymous1_e__Struct - {{ - public {expectedManagedType} value1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L23_C13"")] - public _Anonymous_e__Struct Anonymous; - - public partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} value; - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous2_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} value2; - }} - - [InlineArray(4)] - public partial struct _buffer1_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - - [InlineArray(4)] - public partial struct _buffer2_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int x; - - public int y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int z - { - get - { - return ref Anonymous.z; - } - } - - [UnscopedRef] - public ref int w - { - get - { - return ref Anonymous.Anonymous1.w; - } - } - - public int o0_b0_16 - { - readonly get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - readonly get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - public partial struct _Anonymous_e__Struct - { - public int z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - public partial struct _Anonymous1_e__Struct - { - public int w; - - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - readonly get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - readonly get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public new int Equals; - - public int Dispose; - - public new int GetHashCode; - - public new int GetType; - - public new int MemberwiseClone; - - public new int ReferenceEquals; - - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var usingStatement = "using System.Runtime.InteropServices;\n\n"; - var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; - - if (!Environment.Is64BitProcess) - { - usingStatement = string.Empty; - packing = string.Empty; - } - - var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct1 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} - -{packing} public unsafe partial struct MyStruct2 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - [NativeTypeName(""example_t *"")] - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public double r; - - public double g; - - public double b; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref double a - { - get - { - return ref Anonymous.a; - } - } - - public partial struct _Anonymous_e__Struct - { - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public void MyMethod() - { - } - } - - [NativeTypeName(""struct MyStruct1B : MyStruct1A"")] - public partial struct MyStruct1B - { - public void MyMethod() - { - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - internal partial struct MyStruct1 - { - private int Field1; - - public int Field2; - } - - internal partial struct MyStruct2 - { - private int Field1; - - public int Field2; - } - - public partial struct MyStruct3 - { - private int Field1; - - internal int Field2; - } -} -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"typedef int size_t; - -struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] - public partial struct MyStruct - { - [NativeTypeName(""size_t[2]"")] - public _FixedBuffer_e__FixedBuffer FixedBuffer; - - [InlineArray(2)] - public partial struct _FixedBuffer_e__FixedBuffer - { - public nuint e0; - } - } -} -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @"namespace ClangSharp.Test -{ - [SourceLocation(""ClangUnsavedFile.h"", 1, 8)] - public partial struct MyStruct - { - [SourceLocation(""ClangUnsavedFile.h"", 3, 9)] - public int r; - - [SourceLocation(""ClangUnsavedFile.h"", 4, 9)] - public int g; - - [SourceLocation(""ClangUnsavedFile.h"", 5, 9)] - public int b; - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{ - public partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [NativeTypeName(""struct (anonymous struct at ClangUnsavedFile.h:4:5)[2]"")] - public _MyArray_e__FixedBuffer MyArray; - - [UnscopedRef] - public ref int First - { - get - { - return ref Anonymous.First; - } - } - - public partial struct _Anonymous_e__Struct - { - public int First; - } - - public partial struct _MyArray_e__Struct - { - public int Second; - } - - [InlineArray(2)] - public partial struct _MyArray_e__FixedBuffer - { - public _MyArray_e__Struct e0; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct;"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int Value1 - { - get - { - return ref Anonymous.Anonymous1.Anonymous2.Value1; - } - } - - [UnscopedRef] - public ref int Value2 - { - get - { - return ref Anonymous.Anonymous1.Anonymous3.Value2; - } - } - - public partial struct _Anonymous_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C14"")] - public _Anonymous1_e__Struct Anonymous1; - - public partial struct _Anonymous1_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C9"")] - public _Anonymous2_e__Struct Anonymous2; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L5_C9"")] - public _Anonymous3_e__Struct Anonymous3; - - public partial struct _Anonymous2_e__Struct - { - public int Value1; - } - - public partial struct _Anonymous3_e__Struct - { - public int Value2; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/UnionDeclarationTest.cs deleted file mode 100644 index 19eb4459..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/UnionDeclarationTest.cs +++ /dev/null @@ -1,1513 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpDefaultUnix_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - {{ - readonly get - {{ - return _bitfield1 & 0xFFFFFFu; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - }} - }} - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - {{ - readonly get - {{ - return _bitfield2 & 0xFFFFu; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - }} - }} - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - {{ - readonly get - {{ - return (_bitfield2 >> 16) & 0x7u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - }} - }} - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - {{ - readonly get - {{ - return (int)(_bitfield2 << 10) >> 29; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - }} - }} - - [NativeTypeName(""unsigned char : 1"")] - public byte o4_b22_1 - {{ - readonly get - {{ - return (byte)((_bitfield2 >> 22) & 0x1u); - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - }} - }} - - [NativeTypeName(""int : 1"")] - public int o4_b23_1 - {{ - readonly get - {{ - return (int)(_bitfield2 << 8) >> 31; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - }} - }} - - [NativeTypeName(""int : 1"")] - public int o4_b24_1 - {{ - readonly get - {{ - return (int)(_bitfield2 << 7) >> 31; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - readonly get - {{ - return _bitfield1 & 0x1u; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - }} - }} - - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - {{ - readonly get - {{ - return _bitfield2 & 0x1u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion3 - {{ - [FieldOffset(0)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - readonly get - {{ - return _bitfield & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - }} - }} - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - {{ - readonly get - {{ - return (_bitfield >> 1) & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public int x; - }} - - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyUnion1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyUnion2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref {expectedManagedType} a - {{ - get - {{ - return ref Anonymous.a; - }} - }} - - [UnscopedRef] - public ref MyStruct s - {{ - get - {{ - return ref Anonymous.s; - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> buffer - {{ - get - {{ - return Anonymous.buffer; - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} a; - - [FieldOffset(0)] - public MyStruct s; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[4]"")] - public _buffer_e__FixedBuffer buffer; - - [InlineArray(4)] - public partial struct _buffer_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public int y; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref int z - { - get - { - return ref Anonymous.z; - } - } - - [UnscopedRef] - public ref int w - { - get - { - return ref Anonymous.Anonymous1.w; - } - } - - public int o0_b0_16 - { - readonly get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - readonly get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public int z; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Union Anonymous1; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous1_e__Union - { - [FieldOffset(0)] - public int w; - - [FieldOffset(0)] - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - readonly get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - readonly get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public new int Equals; - - [FieldOffset(0)] - public int Dispose; - - [FieldOffset(0)] - public new int GetHashCode; - - [FieldOffset(0)] - public new int GetType; - - [FieldOffset(0)] - public new int MemberwiseClone; - - [FieldOffset(0)] - public new int ReferenceEquals; - - [FieldOffset(0)] - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - [NativeTypeName(""example_t *"")] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - public double r; - - [FieldOffset(0)] - public double g; - - [FieldOffset(0)] - public double b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref double a - { - get - { - return ref Anonymous.a; - } - } - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@"using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct _MY_UNION - {{ - [FieldOffset(0)] - [NativeTypeName(""long[2]"")] - public _AsArray_e__FixedBuffer AsArray; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref nint First - {{ - get - {{ - return ref Anonymous.First; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A - {{ - get - {{ - return ref Anonymous.Anonymous.A; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B - {{ - get - {{ - return ref Anonymous.Anonymous.B; - }} - }} - - public partial struct _Anonymous_e__Struct - {{ - [NativeTypeName(""long"")] - public nint First; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C9"")] - public _Anonymous_e__Union Anonymous; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L9_C13"")] - public _A_e__Struct A; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C13"")] - public _B_e__Struct B; - - public partial struct _A_e__Struct - {{ - [NativeTypeName(""long"")] - public nint Second; - }} - - public partial struct _B_e__Struct - {{ - [NativeTypeName(""long"")] - public nint Second; - }} - }} - }} - - [InlineArray(2)] - public partial struct _AsArray_e__FixedBuffer - {{ - public nint e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/VarDeclarationTest.cs deleted file mode 100644 index 0433d111..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultUnix/VarDeclarationTest.cs +++ /dev/null @@ -1,410 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpDefaultUnix_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""{nativeType}"")] - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const GUID"")] - public static readonly Guid IID_IUnknown = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - }} -}} -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 {nativeValue}"")] - public const {expectedManagedType} MyMacro1 = {expectedManagedValue}; - - [NativeTypeName(""#define MyMacro2 MyMacro1"")] - public const {expectedManagedType} MyMacro2 = {expectedManagedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 0 + \\\n1"")] - public const int MyMacro1 = 0 + 1; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] - public static ReadOnlySpan MyMacro1 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] - public const string MyMacro1 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; - - [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; - - [NativeTypeName(""const wchar_t *const"")] - public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; - - [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; - - [NativeTypeName(""const wchar_t *const"")] - public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 (long)0x80000000L"")] - public static readonly nint MyMacro1 = unchecked((nint)(0x80000000)); - - [NativeTypeName(""#define MyMacro2 (int)0x80000000"")] - public const int MyMacro2 = unchecked((int)(0x80000000)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 unsigned(-1)"")] - public const uint MyMacro1 = unchecked((uint)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro3 MyMacro2(3)"")] - public const int MyMacro3 = unchecked((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 ((int*) -1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 reinterpret_cast(-1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const int[2][2]"")] - public static readonly int[][] MyArray = new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }}; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"")] - public const int ADDRESS_IN_USE = unchecked((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))); - }} -}} -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/CXXMethodDeclarationTest.cs deleted file mode 100644 index 3b6c0c73..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,424 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpDefaultWindows_CXXMethodDeclarationTest : CXXMethodDeclarationCSharpTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [NativeTypeName(""struct MyStruct : MyTemplate"")] - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern int* DoWork(MyStruct* pThis, int* value = null); - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - if (!Environment.Is64BitProcess) - { - entryPoint = "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - else - { - entryPoint = "?MyVoidMethod@MyStruct@@QEAAXXZ"; - } - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(MyStruct* pThis); - - public int MyInt32Method() - {{ - return 0; - }} - - public void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - public int GetType(int objA, int objB) - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public new int GetType() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int obj) - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public Vtbl* lpVtbl; - - public int GetType(int objA, int objB) - {{ - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public new int GetType() - {{ - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int obj) - {{ - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public partial struct Vtbl - {{ - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public new delegate* unmanaged[Thiscall] GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType1; - - [NativeTypeName(""int (int){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct : MyStruct.Interface - {{ - public Vtbl* lpVtbl; - - public int GetType(int objA, int objB) - {{ - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public new int GetType() - {{ - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int obj) - {{ - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public interface Interface - {{ - int GetType(int objA, int objB); - - int GetType(); - - int GetType(int obj); - }} - - public partial struct Vtbl - where TSelf : unmanaged, Interface - {{ - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public new delegate* unmanaged[Thiscall] GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType1; - - [NativeTypeName(""int (int){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(); - - public static int MyInt32Method() - {{ - return 0; - }} - - public static void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - public void MyVoidMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int MyInt32Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public void* MyVoidStarMethod() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - [VtblIndex(0)] - public void MyVoidMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(1)] - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(2)] - public int MyInt32Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(3)] - public void* MyVoidStarMethod() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/DeprecatedToObsoleteTest.cs deleted file mode 100644 index 0135ae7f..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,506 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpDefaultWindows_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - [Obsolete] - MyEnum_Value1, - [Obsolete(""This is obsolete."")] - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum0 - { - MyEnum_Value0, - } - - [Obsolete] - public enum MyEnum1 - { - MyEnum_Value1, - } - - [Obsolete(""This is obsolete."")] - public enum MyEnum2 - { - MyEnum_Value2, - } - - public enum MyEnum3 - { - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable0 = 0; - - [Obsolete] - public static {expectedManagedType} MyVariable1 = 0; - - [Obsolete(""This is obsolete."")] - public static {expectedManagedType} MyVariable2 = 0; - - public static {expectedManagedType} MyVariable3 = 0; - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction0() - { - } - - [Obsolete] - public static void MyFunction1() - { - } - - [Obsolete(""This is obsolete."")] - public static void MyFunction2() - { - } - - public static void MyFunction3() - { - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public int MyFunction0() - {{ - return 0; - }} - - [Obsolete] - public int MyFunction1() - {{ - return 0; - }} - - [Obsolete(""This is obsolete."")] - public int MyFunction2() - {{ - return 0; - }} - - public int MyFunction3() - {{ - return 0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct0 - { - [NativeTypeName(""Callback0"")] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct1 - { - [NativeTypeName(""Callback1"")] - [Obsolete] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct2 - { - [NativeTypeName(""Callback2"")] - [Obsolete(""This is obsolete."")] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct3 - { - [NativeTypeName(""Callback3"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction0(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete] - public static extern void MyFunction1(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete(""This is obsolete."")] - public static extern void MyFunction2(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction3(); - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/DigitsSeparatorTest.cs deleted file mode 100644 index c54271e8..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/DigitsSeparatorTest.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.CSharpDefaultWindows; - -[Platform("win")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyClass - {{ - [NativeTypeName(""const {type}"")] - private const {type} x = {expectedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/EnumDeclarationTest.cs deleted file mode 100644 index 5b394eed..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/EnumDeclarationTest.cs +++ /dev/null @@ -1,610 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpDefaultWindows_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - [NativeTypeName(""{nativeType}"")] - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum1 : int -{ - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, -} MyEnum1; - -namespace Namespace1 -{ - namespace Namespace2 - { - typedef enum _MyEnum2 : int - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } MyEnum2; - - typedef enum _MyEnum3 : int - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } MyEnum3; - - typedef enum _MyEnum4 : int - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } MyEnum4; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, - } - - public enum MyEnum2 - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } - - public enum MyEnum3 - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } - - public enum MyEnum4 - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } -} -"; - - var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - [Flags] - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = 1, - } -} -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using System; -using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0 = (int)(MyEnum)(10), - MyEnum_Value1 = (int)(MyEnum)(MyEnum_Value0), - MyEnum_Value2 = ((int)(MyEnum)(10)) + MyEnum_Value1, - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0 = 10, - } - - public enum MyEnum2 - { - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (int)(MyEnum1)(10), - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = unchecked((int)(0x80000000)), - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, - } -} -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum1 : uint - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.Methods; - -namespace ClangSharp.Test -{ - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } - - public static partial class Methods - { - public const int MyEnum1_Value1 = 1; - } -} -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public const int MyEnum1_Value1 = 1; - - [NativeTypeName(""const int"")] - public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; - } -} -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index 410f1f44..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,1781 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpDefaultWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* pData, int index) - { - return pData[index]; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(bool x, bool y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - break; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction() - { - } - - public static void MyFunction() - { - MyCalledFunction(); - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction(int x, int y) - { - } - - public static void MyFunction() - { - MyCalledFunction(0, 1); - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 2: - case 3: - { - return 5; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } - - public static partial class Methods - { - public static int MyFunction(MyEnum x) - { - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - return condition ? lhs : rhs; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - continue; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction([NativeTypeName(""const void *"")] void* input) - { - return input; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStructA - {{ - public void** lpVtbl; - - public void MyMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); - }} - }} - - [NativeTypeName(""struct MyStructB : MyStructA"")] - public unsafe partial struct MyStructB - {{ - public void** lpVtbl; - - public void MyMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); - }} - }} - - public static unsafe partial class Methods - {{ - public static MyStructB* MyFunction(MyStructA* input) - {{ - return (MyStructB*)(input); - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - int x = 0; - int y = 1, z = 2; - - return x + y + z; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - - return rhs; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition1, int a, int b, bool condition2, int c) - { - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public float x; - - public float y; - - public float z; - - public float w; - } - - public static partial class Methods - { - public static MyStruct MyFunction1() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - } - - public static MyStruct MyFunction2() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static int MyFunction1(MyStruct instance) - { - return instance.value; - } - - public static int MyFunction2(MyStruct* instance) - { - return instance->value; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static bool MyFunction([NativeTypeName(""const MyStruct &"")] MyStruct* lhs, [NativeTypeName(""const MyStruct &"")] MyStruct* rhs) - { - return lhs->value == rhs->value; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction() - { - return null; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static double MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static float MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - return; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int a - { - get - { - return ref Anonymous.a; - } - } - - public partial struct _Anonymous_e__Struct - { - public int a; - } - } - - public static partial class Methods - { - public static void MyFunction() - { - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public double r; - - public double g; - - public double b; - } - - public static partial class Methods - { - public static MyStruct MyFunction() - { - MyStruct myStruct = new MyStruct(); - - return myStruct; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(int value) - { - return &value; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* value) - { - return *value; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static bool MyFunction(bool value) - { - return !value; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return value{opcode}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return {opcode}value; - }} - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index 32facd72..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,428 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpDefaultWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""const float[4]"")] float* color); - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""void (*)()"")] delegate* unmanaged[Cdecl] callback); - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyFunction(); - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeAttr ? $@"[NativeTypeName(""MyTemplate<{nativeType}>"")] " : "")}MyTemplate<{expectedManagedType}> myStruct); - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTemplate"")] - public MyTemplate a; - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport("""", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeNameAttr ? $@"[NativeTypeName(""{nativeType}"")] " : "")}{expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.StdCall, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [SourceLocation(""ClangUnsavedFile.h"", 1, 17)] - public static extern void MyFunction([SourceLocation(""ClangUnsavedFile.h"", 1, 34)] float value); - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(int value, ...);"; - - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(int value, __arglist); - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionPointerDeclarationTest.cs deleted file mode 100644 index 81848773..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpDefaultWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public delegate* unmanaged[Stdcall] _callback; - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback *"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/StructDeclarationTest.cs deleted file mode 100644 index 3c646741..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/StructDeclarationTest.cs +++ /dev/null @@ -1,2088 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpDefaultWindows_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[]"")] - public _x_e__FixedBuffer x; - - public partial struct _x_e__FixedBuffer - {{ - public {expectedManagedType} e0; - - [UnscopedRef] - public ref {expectedManagedType} this[int index] - {{ - get - {{ - return ref Unsafe.Add(ref e0, index); - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - readonly get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - readonly get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - readonly get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - readonly get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - public byte _bitfield3; - - [NativeTypeName(""unsigned char : 1"")] - public byte o8_b0_1 - { - readonly get - { - return (byte)(_bitfield3 & 0x1u); - } - - set - { - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - } - } - - public int _bitfield4; - - [NativeTypeName(""int : 1"")] - public int o12_b0_1 - { - readonly get - { - return (_bitfield4 << 31) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - } - } - - [NativeTypeName(""int : 1"")] - public int o12_b1_1 - { - readonly get - { - return (_bitfield4 << 30) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - } - } - } - - public partial struct MyStruct2 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - readonly get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - readonly get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - [NativeBitfield(""o0_b0_24"", offset: 0, length: 24)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - readonly get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - [NativeBitfield(""o4_b0_16"", offset: 0, length: 16)] - [NativeBitfield(""o4_b16_3"", offset: 16, length: 3)] - [NativeBitfield(""o4_b19_3"", offset: 19, length: 3)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - readonly get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - readonly get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - readonly get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - [NativeBitfield(""o8_b0_1"", offset: 0, length: 1)] - public byte _bitfield3; - - [NativeTypeName(""unsigned char : 1"")] - public byte o8_b0_1 - { - readonly get - { - return (byte)(_bitfield3 & 0x1u); - } - - set - { - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - } - } - - [NativeBitfield(""o12_b0_1"", offset: 0, length: 1)] - [NativeBitfield(""o12_b1_1"", offset: 1, length: 1)] - public int _bitfield4; - - [NativeTypeName(""int : 1"")] - public int o12_b0_1 - { - readonly get - { - return (_bitfield4 << 31) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - } - } - - [NativeTypeName(""int : 1"")] - public int o12_b1_1 - { - readonly get - { - return (_bitfield4 << 30) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - } - } - } - - public partial struct MyStruct2 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - [NativeBitfield(""o8_b0_1"", offset: 0, length: 1)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - readonly get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - [NativeBitfield(""o0_b1_1"", offset: 1, length: 1)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - readonly get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""decltype(&MyFunction)"")] - public delegate* unmanaged[Cdecl] _callback; - } - - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyStruct1 - {{ - public int x; - }} - - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyStruct2 - {{ - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyStruct1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyStruct2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - [NativeInheritance(""MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - struct - {{ - {nativeType} value1; - - struct - {{ - {nativeType} value; - }}; - }}; - - union - {{ - {nativeType} value2; - }}; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - public partial struct MyStruct - {{ - public {expectedManagedType} x; - - public {expectedManagedType} y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref {expectedManagedType} z - {{ - get - {{ - return ref Anonymous.z; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._w_e__Struct w - {{ - get - {{ - return ref Anonymous.w; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value1 - {{ - get - {{ - return ref Anonymous.Anonymous1.value1; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value - {{ - get - {{ - return ref Anonymous.Anonymous1.Anonymous.value; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value2 - {{ - get - {{ - return ref Anonymous.Anonymous2.value2; - }} - }} - - [UnscopedRef] - public ref MyUnion u - {{ - get - {{ - return ref Anonymous.u; - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> buffer1 - {{ - get - {{ - return Anonymous.buffer1; - }} - }} - - [UnscopedRef] - public Span buffer2 - {{ - get - {{ - return Anonymous.buffer2; - }} - }} - - public partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C9"")] - public _w_e__Struct w; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L19_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L29_C9"")] - public _Anonymous2_e__Union Anonymous2; - - public MyUnion u; - - [NativeTypeName(""{nativeType}[4]"")] - public _buffer1_e__FixedBuffer buffer1; - - [NativeTypeName(""MyUnion[4]"")] - public _buffer2_e__FixedBuffer buffer2; - - public partial struct _w_e__Struct - {{ - public {expectedManagedType} value; - }} - - public partial struct _Anonymous1_e__Struct - {{ - public {expectedManagedType} value1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L23_C13"")] - public _Anonymous_e__Struct Anonymous; - - public partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} value; - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous2_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} value2; - }} - - [InlineArray(4)] - public partial struct _buffer1_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - - [InlineArray(4)] - public partial struct _buffer2_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int x; - - public int y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int z - { - get - { - return ref Anonymous.z; - } - } - - [UnscopedRef] - public ref int w - { - get - { - return ref Anonymous.Anonymous1.w; - } - } - - public int o0_b0_16 - { - readonly get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - readonly get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - public partial struct _Anonymous_e__Struct - { - public int z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - public partial struct _Anonymous1_e__Struct - { - public int w; - - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - readonly get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - readonly get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public new int Equals; - - public int Dispose; - - public new int GetHashCode; - - public new int GetType; - - public new int MemberwiseClone; - - public new int ReferenceEquals; - - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var usingStatement = "using System.Runtime.InteropServices;\n\n"; - var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; - - if (!Environment.Is64BitProcess) - { - usingStatement = string.Empty; - packing = string.Empty; - } - - var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct1 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} - -{packing} public unsafe partial struct MyStruct2 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - [NativeTypeName(""example_t *"")] - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public double r; - - public double g; - - public double b; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref double a - { - get - { - return ref Anonymous.a; - } - } - - public partial struct _Anonymous_e__Struct - { - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public void MyMethod() - { - } - } - - [NativeTypeName(""struct MyStruct1B : MyStruct1A"")] - public partial struct MyStruct1B - { - public void MyMethod() - { - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - internal partial struct MyStruct1 - { - private int Field1; - - public int Field2; - } - - internal partial struct MyStruct2 - { - private int Field1; - - public int Field2; - } - - public partial struct MyStruct3 - { - private int Field1; - - internal int Field2; - } -} -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] - public partial struct MyStruct - { - [NativeTypeName(""size_t[2]"")] - public _FixedBuffer_e__FixedBuffer FixedBuffer; - - [InlineArray(2)] - public partial struct _FixedBuffer_e__FixedBuffer - { - public nuint e0; - } - } -} -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @"namespace ClangSharp.Test -{ - [SourceLocation(""ClangUnsavedFile.h"", 1, 8)] - public partial struct MyStruct - { - [SourceLocation(""ClangUnsavedFile.h"", 3, 9)] - public int r; - - [SourceLocation(""ClangUnsavedFile.h"", 4, 9)] - public int g; - - [SourceLocation(""ClangUnsavedFile.h"", 5, 9)] - public int b; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{ - public partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [NativeTypeName(""struct (anonymous struct at ClangUnsavedFile.h:4:5)[2]"")] - public _MyArray_e__FixedBuffer MyArray; - - [UnscopedRef] - public ref int First - { - get - { - return ref Anonymous.First; - } - } - - public partial struct _Anonymous_e__Struct - { - public int First; - } - - public partial struct _MyArray_e__Struct - { - public int Second; - } - - [InlineArray(2)] - public partial struct _MyArray_e__FixedBuffer - { - public _MyArray_e__Struct e0; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct;"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int Value1 - { - get - { - return ref Anonymous.Anonymous1.Anonymous2.Value1; - } - } - - [UnscopedRef] - public ref int Value2 - { - get - { - return ref Anonymous.Anonymous1.Anonymous3.Value2; - } - } - - public partial struct _Anonymous_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C14"")] - public _Anonymous1_e__Struct Anonymous1; - - public partial struct _Anonymous1_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C9"")] - public _Anonymous2_e__Struct Anonymous2; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L5_C9"")] - public _Anonymous3_e__Struct Anonymous3; - - public partial struct _Anonymous2_e__Struct - { - public int Value1; - } - - public partial struct _Anonymous3_e__Struct - { - public int Value2; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/UnionDeclarationTest.cs deleted file mode 100644 index 76398156..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/UnionDeclarationTest.cs +++ /dev/null @@ -1,1519 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpDefaultWindows_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - {{ - readonly get - {{ - return _bitfield1 & 0xFFFFFFu; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - }} - }} - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - {{ - readonly get - {{ - return _bitfield2 & 0xFFFFu; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - }} - }} - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - {{ - readonly get - {{ - return (_bitfield2 >> 16) & 0x7u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - }} - }} - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - {{ - readonly get - {{ - return (int)(_bitfield2 << 10) >> 29; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - }} - }} - - [FieldOffset(0)] - public byte _bitfield3; - - [NativeTypeName(""unsigned char : 1"")] - public byte o8_b0_1 - {{ - readonly get - {{ - return (byte)(_bitfield3 & 0x1u); - }} - - set - {{ - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - }} - }} - - [FieldOffset(0)] - public int _bitfield4; - - [NativeTypeName(""int : 1"")] - public int o12_b0_1 - {{ - readonly get - {{ - return (_bitfield4 << 31) >> 31; - }} - - set - {{ - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - }} - }} - - [NativeTypeName(""int : 1"")] - public int o12_b1_1 - {{ - readonly get - {{ - return (_bitfield4 << 30) >> 31; - }} - - set - {{ - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - readonly get - {{ - return _bitfield1 & 0x1u; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - }} - }} - - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - {{ - readonly get - {{ - return _bitfield2 & 0x1u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion3 - {{ - [FieldOffset(0)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - readonly get - {{ - return _bitfield & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - }} - }} - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - {{ - readonly get - {{ - return (_bitfield >> 1) & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public int x; - }} - - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyUnion1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyUnion2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref {expectedManagedType} a - {{ - get - {{ - return ref Anonymous.a; - }} - }} - - [UnscopedRef] - public ref MyStruct s - {{ - get - {{ - return ref Anonymous.s; - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> buffer - {{ - get - {{ - return Anonymous.buffer; - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} a; - - [FieldOffset(0)] - public MyStruct s; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[4]"")] - public _buffer_e__FixedBuffer buffer; - - [InlineArray(4)] - public partial struct _buffer_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public int y; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref int z - { - get - { - return ref Anonymous.z; - } - } - - [UnscopedRef] - public ref int w - { - get - { - return ref Anonymous.Anonymous1.w; - } - } - - public int o0_b0_16 - { - readonly get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - readonly get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public int z; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Union Anonymous1; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous1_e__Union - { - [FieldOffset(0)] - public int w; - - [FieldOffset(0)] - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - readonly get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - readonly get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public new int Equals; - - [FieldOffset(0)] - public int Dispose; - - [FieldOffset(0)] - public new int GetHashCode; - - [FieldOffset(0)] - public new int GetType; - - [FieldOffset(0)] - public new int MemberwiseClone; - - [FieldOffset(0)] - public new int ReferenceEquals; - - [FieldOffset(0)] - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - [NativeTypeName(""example_t *"")] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - public double r; - - [FieldOffset(0)] - public double g; - - [FieldOffset(0)] - public double b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref double a - { - get - { - return ref Anonymous.a; - } - } - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@"using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct _MY_UNION - {{ - [FieldOffset(0)] - [NativeTypeName(""long[2]"")] - public _AsArray_e__FixedBuffer AsArray; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int First - {{ - get - {{ - return ref Anonymous.First; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A - {{ - get - {{ - return ref Anonymous.Anonymous.A; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B - {{ - get - {{ - return ref Anonymous.Anonymous.B; - }} - }} - - public partial struct _Anonymous_e__Struct - {{ - [NativeTypeName(""long"")] - public int First; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C9"")] - public _Anonymous_e__Union Anonymous; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L9_C13"")] - public _A_e__Struct A; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C13"")] - public _B_e__Struct B; - - public partial struct _A_e__Struct - {{ - [NativeTypeName(""long"")] - public int Second; - }} - - public partial struct _B_e__Struct - {{ - [NativeTypeName(""long"")] - public int Second; - }} - }} - }} - - [InlineArray(2)] - public partial struct _AsArray_e__FixedBuffer - {{ - public int e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/VarDeclarationTest.cs deleted file mode 100644 index ab364807..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpDefaultWindows/VarDeclarationTest.cs +++ /dev/null @@ -1,408 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpDefaultWindows_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""{nativeType}"")] - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const GUID"")] - public static readonly Guid IID_IUnknown = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - }} -}} -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 {nativeValue}"")] - public const {expectedManagedType} MyMacro1 = {expectedManagedValue}; - - [NativeTypeName(""#define MyMacro2 MyMacro1"")] - public const {expectedManagedType} MyMacro2 = {expectedManagedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 0 + \\\n1"")] - public const int MyMacro1 = 0 + 1; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] - public static ReadOnlySpan MyMacro1 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] - public const string MyMacro1 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public const string MyConst1 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public const string MyConst1 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 (long)0x80000000L"")] - public const int MyMacro1 = unchecked((int)(0x80000000)); - - [NativeTypeName(""#define MyMacro2 (int)0x80000000"")] - public const int MyMacro2 = unchecked((int)(0x80000000)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 unsigned(-1)"")] - public const uint MyMacro1 = unchecked((uint)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro3 MyMacro2(3)"")] - public const int MyMacro3 = unchecked((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 ((int*) -1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 reinterpret_cast(-1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const int[2][2]"")] - public static readonly int[][] MyArray = new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }}; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"")] - public const int ADDRESS_IN_USE = unchecked((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))); - }} -}} -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs deleted file mode 100644 index a3b7736d..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,419 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpLatestUnix_CXXMethodDeclarationTest : CXXMethodDeclarationCSharpTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [NativeTypeName(""struct MyStruct : MyTemplate"")] - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern int* DoWork(MyStruct* pThis, int* value = null); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = Environment.Is64BitProcess - ? "?MyVoidMethod@MyStruct@@QEAAXXZ" - : "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(MyStruct* pThis); - - public int MyInt32Method() - {{ - return 0; - }} - - public void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - public int GetType(int obj) - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public new int GetType() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int objA, int objB) - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public Vtbl* lpVtbl; - - public int GetType(int obj) - {{ - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public new int GetType() - {{ - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int objA, int objB) - {{ - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public partial struct Vtbl - {{ - [NativeTypeName(""int (int){nativeCallConv}"")] - public new delegate* unmanaged[Thiscall] GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType1; - - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct : MyStruct.Interface - {{ - public Vtbl* lpVtbl; - - public int GetType(int obj) - {{ - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public new int GetType() - {{ - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int objA, int objB) - {{ - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public interface Interface - {{ - int GetType(int obj); - - int GetType(); - - int GetType(int objA, int objB); - }} - - public partial struct Vtbl - where TSelf : unmanaged, Interface - {{ - [NativeTypeName(""int (int){nativeCallConv}"")] - public new delegate* unmanaged[Thiscall] GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType1; - - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(); - - public static int MyInt32Method() - {{ - return 0; - }} - - public static void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - public void MyVoidMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int MyInt32Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public void* MyVoidStarMethod() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - [VtblIndex(0)] - public void MyVoidMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(1)] - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(2)] - public int MyInt32Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(3)] - public void* MyVoidStarMethod() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/DeprecatedToObsoleteTest.cs deleted file mode 100644 index 25abcf97..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,506 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpLatestUnix_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - [Obsolete] - MyEnum_Value1, - [Obsolete(""This is obsolete."")] - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum0 - { - MyEnum_Value0, - } - - [Obsolete] - public enum MyEnum1 - { - MyEnum_Value1, - } - - [Obsolete(""This is obsolete."")] - public enum MyEnum2 - { - MyEnum_Value2, - } - - public enum MyEnum3 - { - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable0 = 0; - - [Obsolete] - public static {expectedManagedType} MyVariable1 = 0; - - [Obsolete(""This is obsolete."")] - public static {expectedManagedType} MyVariable2 = 0; - - public static {expectedManagedType} MyVariable3 = 0; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction0() - { - } - - [Obsolete] - public static void MyFunction1() - { - } - - [Obsolete(""This is obsolete."")] - public static void MyFunction2() - { - } - - public static void MyFunction3() - { - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public int MyFunction0() - {{ - return 0; - }} - - [Obsolete] - public int MyFunction1() - {{ - return 0; - }} - - [Obsolete(""This is obsolete."")] - public int MyFunction2() - {{ - return 0; - }} - - public int MyFunction3() - {{ - return 0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct0 - { - [NativeTypeName(""Callback0"")] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct1 - { - [NativeTypeName(""Callback1"")] - [Obsolete] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct2 - { - [NativeTypeName(""Callback2"")] - [Obsolete(""This is obsolete."")] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct3 - { - [NativeTypeName(""Callback3"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction0(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete] - public static extern void MyFunction1(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete(""This is obsolete."")] - public static extern void MyFunction2(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction3(); - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/DigitsSeparatorTest.cs deleted file mode 100644 index b835ab0e..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/DigitsSeparatorTest.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.CSharpLatestUnix; - -[Platform("unix")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyClass - {{ - [NativeTypeName(""const {type}"")] - private const {type} x = {expectedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs deleted file mode 100644 index a29d6522..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/EnumDeclarationTest.cs +++ /dev/null @@ -1,611 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpLatestUnix_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - [NativeTypeName(""{nativeType}"")] - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum1 : int -{ - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, -} MyEnum1; - -namespace Namespace1 -{ - namespace Namespace2 - { - typedef enum _MyEnum2 : int - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } MyEnum2; - - typedef enum _MyEnum3 : int - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } MyEnum3; - - typedef enum _MyEnum4 : int - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } MyEnum4; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, - } - - public enum MyEnum2 - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } - - public enum MyEnum3 - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } - - public enum MyEnum4 - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } -} -"; - - var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - [Flags] - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = 1, - } -} -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using System; -using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0 = (int)(MyEnum)(10), - MyEnum_Value1 = (int)(MyEnum)(MyEnum_Value0), - MyEnum_Value2 = ((int)(MyEnum)(10)) + MyEnum_Value1, - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0 = 10, - } - - public enum MyEnum2 - { - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (int)(MyEnum1)(10), - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = unchecked((int)(0x80000000)), - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, - } -} -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum1 : uint - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.Methods; - -namespace ClangSharp.Test -{ - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } - - public static partial class Methods - { - public const uint MyEnum1_Value1 = 1; - } -} -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public const uint MyEnum1_Value1 = 1; - - [NativeTypeName(""const int"")] - public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; - } -} -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index 1c8e0f1c..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,1781 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpLatestUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* pData, int index) - { - return pData[index]; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(bool x, bool y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - break; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction() - { - } - - public static void MyFunction() - { - MyCalledFunction(); - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction(int x, int y) - { - } - - public static void MyFunction() - { - MyCalledFunction(0, 1); - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 2: - case 3: - { - return 5; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } - - public static partial class Methods - { - public static int MyFunction(MyEnum x) - { - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - return condition ? lhs : rhs; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - continue; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction([NativeTypeName(""const void *"")] void* input) - { - return input; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStructA - {{ - public void** lpVtbl; - - public void MyMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); - }} - }} - - [NativeTypeName(""struct MyStructB : MyStructA"")] - public unsafe partial struct MyStructB - {{ - public void** lpVtbl; - - public void MyMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); - }} - }} - - public static unsafe partial class Methods - {{ - public static MyStructB* MyFunction(MyStructA* input) - {{ - return (MyStructB*)(input); - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - int x = 0; - int y = 1, z = 2; - - return x + y + z; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - - return rhs; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition1, int a, int b, bool condition2, int c) - { - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public float x; - - public float y; - - public float z; - - public float w; - } - - public static partial class Methods - { - public static MyStruct MyFunction1() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - } - - public static MyStruct MyFunction2() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static int MyFunction1(MyStruct instance) - { - return instance.value; - } - - public static int MyFunction2(MyStruct* instance) - { - return instance->value; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static bool MyFunction([NativeTypeName(""const MyStruct &"")] MyStruct* lhs, [NativeTypeName(""const MyStruct &"")] MyStruct* rhs) - { - return lhs->value == rhs->value; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction() - { - return null; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static double MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static float MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - return; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int a - { - get - { - return ref Anonymous.a; - } - } - - public partial struct _Anonymous_e__Struct - { - public int a; - } - } - - public static partial class Methods - { - public static void MyFunction() - { - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public double r; - - public double g; - - public double b; - } - - public static partial class Methods - { - public static MyStruct MyFunction() - { - MyStruct myStruct = new MyStruct(); - - return myStruct; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(int value) - { - return &value; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* value) - { - return *value; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static bool MyFunction(bool value) - { - return !value; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return value{opcode}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return {opcode}value; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index f79b003e..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,411 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpLatestUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""const float[4]"")] float* color); - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""void (*)()"")] delegate* unmanaged[Cdecl] callback); - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyFunction(); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeAttr ? $@"[NativeTypeName(""MyTemplate<{nativeType}>"")] " : "")}MyTemplate<{expectedManagedType}> myStruct); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTemplate"")] - public MyTemplate a; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport("""", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeNameAttr ? $@"[NativeTypeName(""{nativeType}"")] " : "")}{expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.StdCall, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [SourceLocation(""ClangUnsavedFile.h"", 1, 17)] - public static extern void MyFunction([SourceLocation(""ClangUnsavedFile.h"", 1, 34)] float value); - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionPointerDeclarationTest.cs deleted file mode 100644 index e7253c5b..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpLatestUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public delegate* unmanaged[Stdcall] _callback; - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback *"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs deleted file mode 100644 index 936165db..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/StructDeclarationTest.cs +++ /dev/null @@ -1,2082 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpLatestUnix_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[]"")] - public _x_e__FixedBuffer x; - - public partial struct _x_e__FixedBuffer - {{ - public {expectedManagedType} e0; - - [UnscopedRef] - public ref {expectedManagedType} this[int index] - {{ - get - {{ - return ref Unsafe.Add(ref e0, index); - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - readonly get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - readonly get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - readonly get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - readonly get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - [NativeTypeName(""unsigned char : 1"")] - public byte o4_b22_1 - { - readonly get - { - return (byte)((_bitfield2 >> 22) & 0x1u); - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b23_1 - { - readonly get - { - return (int)(_bitfield2 << 8) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b24_1 - { - readonly get - { - return (int)(_bitfield2 << 7) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - } - } - } - - public partial struct MyStruct2 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - readonly get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - readonly get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - [NativeBitfield(""o0_b0_24"", offset: 0, length: 24)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - readonly get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - [NativeBitfield(""o4_b0_16"", offset: 0, length: 16)] - [NativeBitfield(""o4_b16_3"", offset: 16, length: 3)] - [NativeBitfield(""o4_b19_3"", offset: 19, length: 3)] - [NativeBitfield(""o4_b22_1"", offset: 22, length: 1)] - [NativeBitfield(""o4_b23_1"", offset: 23, length: 1)] - [NativeBitfield(""o4_b24_1"", offset: 24, length: 1)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - readonly get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - readonly get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - readonly get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - [NativeTypeName(""unsigned char : 1"")] - public byte o4_b22_1 - { - readonly get - { - return (byte)((_bitfield2 >> 22) & 0x1u); - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b23_1 - { - readonly get - { - return (int)(_bitfield2 << 8) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b24_1 - { - readonly get - { - return (int)(_bitfield2 << 7) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - } - } - } - - public partial struct MyStruct2 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - [NativeBitfield(""o8_b0_1"", offset: 0, length: 1)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - readonly get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - [NativeBitfield(""o0_b1_1"", offset: 1, length: 1)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - readonly get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""decltype(&MyFunction)"")] - public delegate* unmanaged[Cdecl] _callback; - } - - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyStruct1 - {{ - public int x; - }} - - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyStruct2 - {{ - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyStruct1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyStruct2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - [NativeInheritance(""MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - struct - {{ - {nativeType} value1; - - struct - {{ - {nativeType} value; - }}; - }}; - - union - {{ - {nativeType} value2; - }}; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - public partial struct MyStruct - {{ - public {expectedManagedType} x; - - public {expectedManagedType} y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref {expectedManagedType} z - {{ - get - {{ - return ref Anonymous.z; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._w_e__Struct w - {{ - get - {{ - return ref Anonymous.w; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value1 - {{ - get - {{ - return ref Anonymous.Anonymous1.value1; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value - {{ - get - {{ - return ref Anonymous.Anonymous1.Anonymous.value; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value2 - {{ - get - {{ - return ref Anonymous.Anonymous2.value2; - }} - }} - - [UnscopedRef] - public ref MyUnion u - {{ - get - {{ - return ref Anonymous.u; - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> buffer1 - {{ - get - {{ - return Anonymous.buffer1; - }} - }} - - [UnscopedRef] - public Span buffer2 - {{ - get - {{ - return Anonymous.buffer2; - }} - }} - - public partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C9"")] - public _w_e__Struct w; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L19_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L29_C9"")] - public _Anonymous2_e__Union Anonymous2; - - public MyUnion u; - - [NativeTypeName(""{nativeType}[4]"")] - public _buffer1_e__FixedBuffer buffer1; - - [NativeTypeName(""MyUnion[4]"")] - public _buffer2_e__FixedBuffer buffer2; - - public partial struct _w_e__Struct - {{ - public {expectedManagedType} value; - }} - - public partial struct _Anonymous1_e__Struct - {{ - public {expectedManagedType} value1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L23_C13"")] - public _Anonymous_e__Struct Anonymous; - - public partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} value; - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous2_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} value2; - }} - - [InlineArray(4)] - public partial struct _buffer1_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - - [InlineArray(4)] - public partial struct _buffer2_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int x; - - public int y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int z - { - get - { - return ref Anonymous.z; - } - } - - [UnscopedRef] - public ref int w - { - get - { - return ref Anonymous.Anonymous1.w; - } - } - - public int o0_b0_16 - { - readonly get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - readonly get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - public partial struct _Anonymous_e__Struct - { - public int z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - public partial struct _Anonymous1_e__Struct - { - public int w; - - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - readonly get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - readonly get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public new int Equals; - - public int Dispose; - - public new int GetHashCode; - - public new int GetType; - - public new int MemberwiseClone; - - public new int ReferenceEquals; - - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var usingStatement = "using System.Runtime.InteropServices;\n\n"; - var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; - - if (!Environment.Is64BitProcess) - { - usingStatement = string.Empty; - packing = string.Empty; - } - - var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct1 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} - -{packing} public unsafe partial struct MyStruct2 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - [NativeTypeName(""example_t *"")] - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public double r; - - public double g; - - public double b; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref double a - { - get - { - return ref Anonymous.a; - } - } - - public partial struct _Anonymous_e__Struct - { - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public void MyMethod() - { - } - } - - [NativeTypeName(""struct MyStruct1B : MyStruct1A"")] - public partial struct MyStruct1B - { - public void MyMethod() - { - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - internal partial struct MyStruct1 - { - private int Field1; - - public int Field2; - } - - internal partial struct MyStruct2 - { - private int Field1; - - public int Field2; - } - - public partial struct MyStruct3 - { - private int Field1; - - internal int Field2; - } -} -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"typedef int size_t; - -struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] - public partial struct MyStruct - { - [NativeTypeName(""size_t[2]"")] - public _FixedBuffer_e__FixedBuffer FixedBuffer; - - [InlineArray(2)] - public partial struct _FixedBuffer_e__FixedBuffer - { - public nuint e0; - } - } -} -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @"namespace ClangSharp.Test -{ - [SourceLocation(""ClangUnsavedFile.h"", 1, 8)] - public partial struct MyStruct - { - [SourceLocation(""ClangUnsavedFile.h"", 3, 9)] - public int r; - - [SourceLocation(""ClangUnsavedFile.h"", 4, 9)] - public int g; - - [SourceLocation(""ClangUnsavedFile.h"", 5, 9)] - public int b; - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{ - public partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [NativeTypeName(""struct (anonymous struct at ClangUnsavedFile.h:4:5)[2]"")] - public _MyArray_e__FixedBuffer MyArray; - - [UnscopedRef] - public ref int First - { - get - { - return ref Anonymous.First; - } - } - - public partial struct _Anonymous_e__Struct - { - public int First; - } - - public partial struct _MyArray_e__Struct - { - public int Second; - } - - [InlineArray(2)] - public partial struct _MyArray_e__FixedBuffer - { - public _MyArray_e__Struct e0; - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct;"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int Value1 - { - get - { - return ref Anonymous.Anonymous1.Anonymous2.Value1; - } - } - - [UnscopedRef] - public ref int Value2 - { - get - { - return ref Anonymous.Anonymous1.Anonymous3.Value2; - } - } - - public partial struct _Anonymous_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C14"")] - public _Anonymous1_e__Struct Anonymous1; - - public partial struct _Anonymous1_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C9"")] - public _Anonymous2_e__Struct Anonymous2; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L5_C9"")] - public _Anonymous3_e__Struct Anonymous3; - - public partial struct _Anonymous2_e__Struct - { - public int Value1; - } - - public partial struct _Anonymous3_e__Struct - { - public int Value2; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs deleted file mode 100644 index 64f424df..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/UnionDeclarationTest.cs +++ /dev/null @@ -1,1513 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpLatestUnix_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - {{ - readonly get - {{ - return _bitfield1 & 0xFFFFFFu; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - }} - }} - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - {{ - readonly get - {{ - return _bitfield2 & 0xFFFFu; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - }} - }} - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - {{ - readonly get - {{ - return (_bitfield2 >> 16) & 0x7u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - }} - }} - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - {{ - readonly get - {{ - return (int)(_bitfield2 << 10) >> 29; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - }} - }} - - [NativeTypeName(""unsigned char : 1"")] - public byte o4_b22_1 - {{ - readonly get - {{ - return (byte)((_bitfield2 >> 22) & 0x1u); - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - }} - }} - - [NativeTypeName(""int : 1"")] - public int o4_b23_1 - {{ - readonly get - {{ - return (int)(_bitfield2 << 8) >> 31; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - }} - }} - - [NativeTypeName(""int : 1"")] - public int o4_b24_1 - {{ - readonly get - {{ - return (int)(_bitfield2 << 7) >> 31; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - readonly get - {{ - return _bitfield1 & 0x1u; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - }} - }} - - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - {{ - readonly get - {{ - return _bitfield2 & 0x1u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion3 - {{ - [FieldOffset(0)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - readonly get - {{ - return _bitfield & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - }} - }} - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - {{ - readonly get - {{ - return (_bitfield >> 1) & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public int x; - }} - - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyUnion1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyUnion2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref {expectedManagedType} a - {{ - get - {{ - return ref Anonymous.a; - }} - }} - - [UnscopedRef] - public ref MyStruct s - {{ - get - {{ - return ref Anonymous.s; - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> buffer - {{ - get - {{ - return Anonymous.buffer; - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} a; - - [FieldOffset(0)] - public MyStruct s; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[4]"")] - public _buffer_e__FixedBuffer buffer; - - [InlineArray(4)] - public partial struct _buffer_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public int y; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref int z - { - get - { - return ref Anonymous.z; - } - } - - [UnscopedRef] - public ref int w - { - get - { - return ref Anonymous.Anonymous1.w; - } - } - - public int o0_b0_16 - { - readonly get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - readonly get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public int z; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Union Anonymous1; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous1_e__Union - { - [FieldOffset(0)] - public int w; - - [FieldOffset(0)] - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - readonly get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - readonly get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public new int Equals; - - [FieldOffset(0)] - public int Dispose; - - [FieldOffset(0)] - public new int GetHashCode; - - [FieldOffset(0)] - public new int GetType; - - [FieldOffset(0)] - public new int MemberwiseClone; - - [FieldOffset(0)] - public new int ReferenceEquals; - - [FieldOffset(0)] - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - [NativeTypeName(""example_t *"")] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - public double r; - - [FieldOffset(0)] - public double g; - - [FieldOffset(0)] - public double b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref double a - { - get - { - return ref Anonymous.a; - } - } - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@"using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct _MY_UNION - {{ - [FieldOffset(0)] - [NativeTypeName(""long[2]"")] - public _AsArray_e__FixedBuffer AsArray; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref nint First - {{ - get - {{ - return ref Anonymous.First; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A - {{ - get - {{ - return ref Anonymous.Anonymous.A; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B - {{ - get - {{ - return ref Anonymous.Anonymous.B; - }} - }} - - public partial struct _Anonymous_e__Struct - {{ - [NativeTypeName(""long"")] - public nint First; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C9"")] - public _Anonymous_e__Union Anonymous; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L9_C13"")] - public _A_e__Struct A; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C13"")] - public _B_e__Struct B; - - public partial struct _A_e__Struct - {{ - [NativeTypeName(""long"")] - public nint Second; - }} - - public partial struct _B_e__Struct - {{ - [NativeTypeName(""long"")] - public nint Second; - }} - }} - }} - - [InlineArray(2)] - public partial struct _AsArray_e__FixedBuffer - {{ - public nint e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs deleted file mode 100644 index dfc9e8de..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestUnix/VarDeclarationTest.cs +++ /dev/null @@ -1,410 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpLatestUnix_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""{nativeType}"")] - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const GUID"")] - public static readonly Guid IID_IUnknown = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - }} -}} -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 {nativeValue}"")] - public const {expectedManagedType} MyMacro1 = {expectedManagedValue}; - - [NativeTypeName(""#define MyMacro2 MyMacro1"")] - public const {expectedManagedType} MyMacro2 = {expectedManagedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 0 + \\\n1"")] - public const int MyMacro1 = 0 + 1; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] - public static ReadOnlySpan MyMacro1 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] - public const string MyMacro1 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; - - [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; - - [NativeTypeName(""const wchar_t *const"")] - public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public static readonly uint[] MyConst1 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; - - [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; - - [NativeTypeName(""const wchar_t *const"")] - public static readonly uint[] MyConst3 = new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }}; - }} -}} -"; - - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 (long)0x80000000L"")] - public static readonly nint MyMacro1 = unchecked((nint)(0x80000000)); - - [NativeTypeName(""#define MyMacro2 (int)0x80000000"")] - public const int MyMacro2 = unchecked((int)(0x80000000)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 unsigned(-1)"")] - public const uint MyMacro1 = unchecked((uint)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro3 MyMacro2(3)"")] - public const int MyMacro3 = unchecked((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 ((int*) -1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 reinterpret_cast(-1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const int[2][2]"")] - public static readonly int[][] MyArray = new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }}; - }} -}} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"")] - public const int ADDRESS_IN_USE = unchecked((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))); - }} -}} -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs deleted file mode 100644 index f4ed0603..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,419 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpLatestWindows_CXXMethodDeclarationTest : CXXMethodDeclarationCSharpTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [NativeTypeName(""struct MyStruct : MyTemplate"")] - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern int* DoWork(MyStruct* pThis, int* value = null); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = Environment.Is64BitProcess - ? "?MyVoidMethod@MyStruct@@QEAAXXZ" - : "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(MyStruct* pThis); - - public int MyInt32Method() - {{ - return 0; - }} - - public void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - public int GetType(int objA, int objB) - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public new int GetType() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int obj) - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public Vtbl* lpVtbl; - - public int GetType(int objA, int objB) - {{ - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public new int GetType() - {{ - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int obj) - {{ - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public partial struct Vtbl - {{ - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public new delegate* unmanaged[Thiscall] GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType1; - - [NativeTypeName(""int (int){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct : MyStruct.Interface - {{ - public Vtbl* lpVtbl; - - public int GetType(int objA, int objB) - {{ - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public new int GetType() - {{ - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int obj) - {{ - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public interface Interface - {{ - int GetType(int objA, int objB); - - int GetType(); - - int GetType(int obj); - }} - - public partial struct Vtbl - where TSelf : unmanaged, Interface - {{ - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public new delegate* unmanaged[Thiscall] GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType1; - - [NativeTypeName(""int (int){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(); - - public static int MyInt32Method() - {{ - return 0; - }} - - public static void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - public void MyVoidMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int MyInt32Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public void* MyVoidStarMethod() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - [VtblIndex(0)] - public void MyVoidMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(1)] - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(2)] - public int MyInt32Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(3)] - public void* MyVoidStarMethod() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/DeprecatedToObsoleteTest.cs deleted file mode 100644 index dfd968ac..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,506 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpLatestWindows_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - [Obsolete] - MyEnum_Value1, - [Obsolete(""This is obsolete."")] - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum0 - { - MyEnum_Value0, - } - - [Obsolete] - public enum MyEnum1 - { - MyEnum_Value1, - } - - [Obsolete(""This is obsolete."")] - public enum MyEnum2 - { - MyEnum_Value2, - } - - public enum MyEnum3 - { - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable0 = 0; - - [Obsolete] - public static {expectedManagedType} MyVariable1 = 0; - - [Obsolete(""This is obsolete."")] - public static {expectedManagedType} MyVariable2 = 0; - - public static {expectedManagedType} MyVariable3 = 0; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction0() - { - } - - [Obsolete] - public static void MyFunction1() - { - } - - [Obsolete(""This is obsolete."")] - public static void MyFunction2() - { - } - - public static void MyFunction3() - { - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public int MyFunction0() - {{ - return 0; - }} - - [Obsolete] - public int MyFunction1() - {{ - return 0; - }} - - [Obsolete(""This is obsolete."")] - public int MyFunction2() - {{ - return 0; - }} - - public int MyFunction3() - {{ - return 0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct0 - { - [NativeTypeName(""Callback0"")] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct1 - { - [NativeTypeName(""Callback1"")] - [Obsolete] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct2 - { - [NativeTypeName(""Callback2"")] - [Obsolete(""This is obsolete."")] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct3 - { - [NativeTypeName(""Callback3"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction0(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete] - public static extern void MyFunction1(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete(""This is obsolete."")] - public static extern void MyFunction2(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction3(); - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/DigitsSeparatorTest.cs deleted file mode 100644 index a1d1fd84..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/DigitsSeparatorTest.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.CSharpLatestWindows; - -[Platform("win")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyClass - {{ - [NativeTypeName(""const {type}"")] - private const {type} x = {expectedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs deleted file mode 100644 index 86a75eb2..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/EnumDeclarationTest.cs +++ /dev/null @@ -1,611 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpLatestWindows_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - [NativeTypeName(""{nativeType}"")] - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum1 : int -{ - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, -} MyEnum1; - -namespace Namespace1 -{ - namespace Namespace2 - { - typedef enum _MyEnum2 : int - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } MyEnum2; - - typedef enum _MyEnum3 : int - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } MyEnum3; - - typedef enum _MyEnum4 : int - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } MyEnum4; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, - } - - public enum MyEnum2 - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } - - public enum MyEnum3 - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } - - public enum MyEnum4 - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } -} -"; - - var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - [Flags] - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = 1, - } -} -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using System; -using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0 = (int)(MyEnum)(10), - MyEnum_Value1 = (int)(MyEnum)(MyEnum_Value0), - MyEnum_Value2 = ((int)(MyEnum)(10)) + MyEnum_Value1, - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0 = 10, - } - - public enum MyEnum2 - { - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (int)(MyEnum1)(10), - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = unchecked((int)(0x80000000)), - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, - } -} -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum1 : uint - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.Methods; - -namespace ClangSharp.Test -{ - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } - - public static partial class Methods - { - public const int MyEnum1_Value1 = 1; - } -} -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public const int MyEnum1_Value1 = 1; - - [NativeTypeName(""const int"")] - public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; - } -} -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index 623eae4f..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,1781 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpLatestWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* pData, int index) - { - return pData[index]; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(bool x, bool y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - break; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction() - { - } - - public static void MyFunction() - { - MyCalledFunction(); - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction(int x, int y) - { - } - - public static void MyFunction() - { - MyCalledFunction(0, 1); - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 2: - case 3: - { - return 5; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } - - public static partial class Methods - { - public static int MyFunction(MyEnum x) - { - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - return condition ? lhs : rhs; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - continue; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction([NativeTypeName(""const void *"")] void* input) - { - return input; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStructA - {{ - public void** lpVtbl; - - public void MyMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); - }} - }} - - [NativeTypeName(""struct MyStructB : MyStructA"")] - public unsafe partial struct MyStructB - {{ - public void** lpVtbl; - - public void MyMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); - }} - }} - - public static unsafe partial class Methods - {{ - public static MyStructB* MyFunction(MyStructA* input) - {{ - return (MyStructB*)(input); - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - int x = 0; - int y = 1, z = 2; - - return x + y + z; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - - return rhs; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition1, int a, int b, bool condition2, int c) - { - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public float x; - - public float y; - - public float z; - - public float w; - } - - public static partial class Methods - { - public static MyStruct MyFunction1() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - } - - public static MyStruct MyFunction2() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static int MyFunction1(MyStruct instance) - { - return instance.value; - } - - public static int MyFunction2(MyStruct* instance) - { - return instance->value; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static bool MyFunction([NativeTypeName(""const MyStruct &"")] MyStruct* lhs, [NativeTypeName(""const MyStruct &"")] MyStruct* rhs) - { - return lhs->value == rhs->value; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction() - { - return null; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static double MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static float MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - return; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int a - { - get - { - return ref Anonymous.a; - } - } - - public partial struct _Anonymous_e__Struct - { - public int a; - } - } - - public static partial class Methods - { - public static void MyFunction() - { - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public double r; - - public double g; - - public double b; - } - - public static partial class Methods - { - public static MyStruct MyFunction() - { - MyStruct myStruct = new MyStruct(); - - return myStruct; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(int value) - { - return &value; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* value) - { - return *value; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static bool MyFunction(bool value) - { - return !value; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return value{opcode}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return {opcode}value; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index 522c1ff5..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,428 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpLatestWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""const float[4]"")] float* color); - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""void (*)()"")] delegate* unmanaged[Cdecl] callback); - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyFunction(); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeAttr ? $@"[NativeTypeName(""MyTemplate<{nativeType}>"")] " : "")}MyTemplate<{expectedManagedType}> myStruct); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTemplate"")] - public MyTemplate a; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport("""", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeNameAttr ? $@"[NativeTypeName(""{nativeType}"")] " : "")}{expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.StdCall, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [SourceLocation(""ClangUnsavedFile.h"", 1, 17)] - public static extern void MyFunction([SourceLocation(""ClangUnsavedFile.h"", 1, 34)] float value); - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(int value, ...);"; - - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(int value, __arglist); - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionPointerDeclarationTest.cs deleted file mode 100644 index 85e996ae..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpLatestWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public delegate* unmanaged[Stdcall] _callback; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback *"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs deleted file mode 100644 index 9661e535..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/StructDeclarationTest.cs +++ /dev/null @@ -1,2088 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpLatestWindows_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[]"")] - public _x_e__FixedBuffer x; - - public partial struct _x_e__FixedBuffer - {{ - public {expectedManagedType} e0; - - [UnscopedRef] - public ref {expectedManagedType} this[int index] - {{ - get - {{ - return ref Unsafe.Add(ref e0, index); - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - readonly get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - readonly get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - readonly get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - readonly get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - public byte _bitfield3; - - [NativeTypeName(""unsigned char : 1"")] - public byte o8_b0_1 - { - readonly get - { - return (byte)(_bitfield3 & 0x1u); - } - - set - { - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - } - } - - public int _bitfield4; - - [NativeTypeName(""int : 1"")] - public int o12_b0_1 - { - readonly get - { - return (_bitfield4 << 31) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - } - } - - [NativeTypeName(""int : 1"")] - public int o12_b1_1 - { - readonly get - { - return (_bitfield4 << 30) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - } - } - } - - public partial struct MyStruct2 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - readonly get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - readonly get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - [NativeBitfield(""o0_b0_24"", offset: 0, length: 24)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - readonly get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - [NativeBitfield(""o4_b0_16"", offset: 0, length: 16)] - [NativeBitfield(""o4_b16_3"", offset: 16, length: 3)] - [NativeBitfield(""o4_b19_3"", offset: 19, length: 3)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - readonly get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - readonly get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - readonly get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - [NativeBitfield(""o8_b0_1"", offset: 0, length: 1)] - public byte _bitfield3; - - [NativeTypeName(""unsigned char : 1"")] - public byte o8_b0_1 - { - readonly get - { - return (byte)(_bitfield3 & 0x1u); - } - - set - { - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - } - } - - [NativeBitfield(""o12_b0_1"", offset: 0, length: 1)] - [NativeBitfield(""o12_b1_1"", offset: 1, length: 1)] - public int _bitfield4; - - [NativeTypeName(""int : 1"")] - public int o12_b0_1 - { - readonly get - { - return (_bitfield4 << 31) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - } - } - - [NativeTypeName(""int : 1"")] - public int o12_b1_1 - { - readonly get - { - return (_bitfield4 << 30) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - } - } - } - - public partial struct MyStruct2 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - [NativeBitfield(""o8_b0_1"", offset: 0, length: 1)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - readonly get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - [NativeBitfield(""o0_b1_1"", offset: 1, length: 1)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - readonly get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""decltype(&MyFunction)"")] - public delegate* unmanaged[Cdecl] _callback; - } - - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyStruct1 - {{ - public int x; - }} - - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyStruct2 - {{ - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyStruct1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyStruct2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - [NativeInheritance(""MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - struct - {{ - {nativeType} value1; - - struct - {{ - {nativeType} value; - }}; - }}; - - union - {{ - {nativeType} value2; - }}; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - public partial struct MyStruct - {{ - public {expectedManagedType} x; - - public {expectedManagedType} y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref {expectedManagedType} z - {{ - get - {{ - return ref Anonymous.z; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._w_e__Struct w - {{ - get - {{ - return ref Anonymous.w; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value1 - {{ - get - {{ - return ref Anonymous.Anonymous1.value1; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value - {{ - get - {{ - return ref Anonymous.Anonymous1.Anonymous.value; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value2 - {{ - get - {{ - return ref Anonymous.Anonymous2.value2; - }} - }} - - [UnscopedRef] - public ref MyUnion u - {{ - get - {{ - return ref Anonymous.u; - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> buffer1 - {{ - get - {{ - return Anonymous.buffer1; - }} - }} - - [UnscopedRef] - public Span buffer2 - {{ - get - {{ - return Anonymous.buffer2; - }} - }} - - public partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C9"")] - public _w_e__Struct w; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L19_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L29_C9"")] - public _Anonymous2_e__Union Anonymous2; - - public MyUnion u; - - [NativeTypeName(""{nativeType}[4]"")] - public _buffer1_e__FixedBuffer buffer1; - - [NativeTypeName(""MyUnion[4]"")] - public _buffer2_e__FixedBuffer buffer2; - - public partial struct _w_e__Struct - {{ - public {expectedManagedType} value; - }} - - public partial struct _Anonymous1_e__Struct - {{ - public {expectedManagedType} value1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L23_C13"")] - public _Anonymous_e__Struct Anonymous; - - public partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} value; - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous2_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} value2; - }} - - [InlineArray(4)] - public partial struct _buffer1_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - - [InlineArray(4)] - public partial struct _buffer2_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int x; - - public int y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int z - { - get - { - return ref Anonymous.z; - } - } - - [UnscopedRef] - public ref int w - { - get - { - return ref Anonymous.Anonymous1.w; - } - } - - public int o0_b0_16 - { - readonly get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - readonly get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - public partial struct _Anonymous_e__Struct - { - public int z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - public partial struct _Anonymous1_e__Struct - { - public int w; - - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - readonly get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - readonly get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public new int Equals; - - public int Dispose; - - public new int GetHashCode; - - public new int GetType; - - public new int MemberwiseClone; - - public new int ReferenceEquals; - - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var usingStatement = "using System.Runtime.InteropServices;\n\n"; - var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; - - if (!Environment.Is64BitProcess) - { - usingStatement = string.Empty; - packing = string.Empty; - } - - var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct1 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} - -{packing} public unsafe partial struct MyStruct2 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - [NativeTypeName(""example_t *"")] - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public double r; - - public double g; - - public double b; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref double a - { - get - { - return ref Anonymous.a; - } - } - - public partial struct _Anonymous_e__Struct - { - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public void MyMethod() - { - } - } - - [NativeTypeName(""struct MyStruct1B : MyStruct1A"")] - public partial struct MyStruct1B - { - public void MyMethod() - { - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - internal partial struct MyStruct1 - { - private int Field1; - - public int Field2; - } - - internal partial struct MyStruct2 - { - private int Field1; - - public int Field2; - } - - public partial struct MyStruct3 - { - private int Field1; - - internal int Field2; - } -} -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] - public partial struct MyStruct - { - [NativeTypeName(""size_t[2]"")] - public _FixedBuffer_e__FixedBuffer FixedBuffer; - - [InlineArray(2)] - public partial struct _FixedBuffer_e__FixedBuffer - { - public nuint e0; - } - } -} -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @"namespace ClangSharp.Test -{ - [SourceLocation(""ClangUnsavedFile.h"", 1, 8)] - public partial struct MyStruct - { - [SourceLocation(""ClangUnsavedFile.h"", 3, 9)] - public int r; - - [SourceLocation(""ClangUnsavedFile.h"", 4, 9)] - public int g; - - [SourceLocation(""ClangUnsavedFile.h"", 5, 9)] - public int b; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{ - public partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [NativeTypeName(""struct (anonymous struct at ClangUnsavedFile.h:4:5)[2]"")] - public _MyArray_e__FixedBuffer MyArray; - - [UnscopedRef] - public ref int First - { - get - { - return ref Anonymous.First; - } - } - - public partial struct _Anonymous_e__Struct - { - public int First; - } - - public partial struct _MyArray_e__Struct - { - public int Second; - } - - [InlineArray(2)] - public partial struct _MyArray_e__FixedBuffer - { - public _MyArray_e__Struct e0; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct;"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int Value1 - { - get - { - return ref Anonymous.Anonymous1.Anonymous2.Value1; - } - } - - [UnscopedRef] - public ref int Value2 - { - get - { - return ref Anonymous.Anonymous1.Anonymous3.Value2; - } - } - - public partial struct _Anonymous_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C14"")] - public _Anonymous1_e__Struct Anonymous1; - - public partial struct _Anonymous1_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C9"")] - public _Anonymous2_e__Struct Anonymous2; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L5_C9"")] - public _Anonymous3_e__Struct Anonymous3; - - public partial struct _Anonymous2_e__Struct - { - public int Value1; - } - - public partial struct _Anonymous3_e__Struct - { - public int Value2; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs deleted file mode 100644 index 72bbf228..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/UnionDeclarationTest.cs +++ /dev/null @@ -1,1519 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpLatestWindows_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - {{ - readonly get - {{ - return _bitfield1 & 0xFFFFFFu; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - }} - }} - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - {{ - readonly get - {{ - return _bitfield2 & 0xFFFFu; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - }} - }} - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - {{ - readonly get - {{ - return (_bitfield2 >> 16) & 0x7u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - }} - }} - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - {{ - readonly get - {{ - return (int)(_bitfield2 << 10) >> 29; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - }} - }} - - [FieldOffset(0)] - public byte _bitfield3; - - [NativeTypeName(""unsigned char : 1"")] - public byte o8_b0_1 - {{ - readonly get - {{ - return (byte)(_bitfield3 & 0x1u); - }} - - set - {{ - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - }} - }} - - [FieldOffset(0)] - public int _bitfield4; - - [NativeTypeName(""int : 1"")] - public int o12_b0_1 - {{ - readonly get - {{ - return (_bitfield4 << 31) >> 31; - }} - - set - {{ - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - }} - }} - - [NativeTypeName(""int : 1"")] - public int o12_b1_1 - {{ - readonly get - {{ - return (_bitfield4 << 30) >> 31; - }} - - set - {{ - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - readonly get - {{ - return _bitfield1 & 0x1u; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - }} - }} - - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - {{ - readonly get - {{ - return _bitfield2 & 0x1u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion3 - {{ - [FieldOffset(0)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - readonly get - {{ - return _bitfield & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - }} - }} - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - {{ - readonly get - {{ - return (_bitfield >> 1) & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public int x; - }} - - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyUnion1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyUnion2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref {expectedManagedType} a - {{ - get - {{ - return ref Anonymous.a; - }} - }} - - [UnscopedRef] - public ref MyStruct s - {{ - get - {{ - return ref Anonymous.s; - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> buffer - {{ - get - {{ - return Anonymous.buffer; - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} a; - - [FieldOffset(0)] - public MyStruct s; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[4]"")] - public _buffer_e__FixedBuffer buffer; - - [InlineArray(4)] - public partial struct _buffer_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public int y; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref int z - { - get - { - return ref Anonymous.z; - } - } - - [UnscopedRef] - public ref int w - { - get - { - return ref Anonymous.Anonymous1.w; - } - } - - public int o0_b0_16 - { - readonly get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - readonly get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public int z; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Union Anonymous1; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous1_e__Union - { - [FieldOffset(0)] - public int w; - - [FieldOffset(0)] - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - readonly get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - readonly get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public new int Equals; - - [FieldOffset(0)] - public int Dispose; - - [FieldOffset(0)] - public new int GetHashCode; - - [FieldOffset(0)] - public new int GetType; - - [FieldOffset(0)] - public new int MemberwiseClone; - - [FieldOffset(0)] - public new int ReferenceEquals; - - [FieldOffset(0)] - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - [NativeTypeName(""example_t *"")] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - public double r; - - [FieldOffset(0)] - public double g; - - [FieldOffset(0)] - public double b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref double a - { - get - { - return ref Anonymous.a; - } - } - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@"using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct _MY_UNION - {{ - [FieldOffset(0)] - [NativeTypeName(""long[2]"")] - public _AsArray_e__FixedBuffer AsArray; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int First - {{ - get - {{ - return ref Anonymous.First; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A - {{ - get - {{ - return ref Anonymous.Anonymous.A; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B - {{ - get - {{ - return ref Anonymous.Anonymous.B; - }} - }} - - public partial struct _Anonymous_e__Struct - {{ - [NativeTypeName(""long"")] - public int First; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C9"")] - public _Anonymous_e__Union Anonymous; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L9_C13"")] - public _A_e__Struct A; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C13"")] - public _B_e__Struct B; - - public partial struct _A_e__Struct - {{ - [NativeTypeName(""long"")] - public int Second; - }} - - public partial struct _B_e__Struct - {{ - [NativeTypeName(""long"")] - public int Second; - }} - }} - }} - - [InlineArray(2)] - public partial struct _AsArray_e__FixedBuffer - {{ - public int e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs deleted file mode 100644 index 877351de..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpLatestWindows/VarDeclarationTest.cs +++ /dev/null @@ -1,408 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpLatestWindows_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""{nativeType}"")] - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const GUID"")] - public static readonly Guid IID_IUnknown = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - }} -}} -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 {nativeValue}"")] - public const {expectedManagedType} MyMacro1 = {expectedManagedValue}; - - [NativeTypeName(""#define MyMacro2 MyMacro1"")] - public const {expectedManagedType} MyMacro2 = {expectedManagedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 0 + \\\n1"")] - public const int MyMacro1 = 0 + 1; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] - public static ReadOnlySpan MyMacro1 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] - public const string MyMacro1 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public const string MyConst1 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public const string MyConst1 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 (long)0x80000000L"")] - public const int MyMacro1 = unchecked((int)(0x80000000)); - - [NativeTypeName(""#define MyMacro2 (int)0x80000000"")] - public const int MyMacro2 = unchecked((int)(0x80000000)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 unsigned(-1)"")] - public const uint MyMacro1 = unchecked((uint)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro3 MyMacro2(3)"")] - public const int MyMacro3 = unchecked((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 ((int*) -1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 reinterpret_cast(-1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const int[2][2]"")] - public static readonly int[][] MyArray = new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }}; - }} -}} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"")] - public const int ADDRESS_IN_USE = unchecked((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))); - }} -}} -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs deleted file mode 100644 index d8b9a251..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,419 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpPreviewUnix_CXXMethodDeclarationTest : CXXMethodDeclarationCSharpTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [NativeTypeName(""struct MyStruct : MyTemplate"")] - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern int* DoWork(MyStruct* pThis, int* value = null); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = Environment.Is64BitProcess - ? "?MyVoidMethod@MyStruct@@QEAAXXZ" - : "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(MyStruct* pThis); - - public int MyInt32Method() - {{ - return 0; - }} - - public void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - public int GetType(int obj) - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public new int GetType() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int objA, int objB) - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public Vtbl* lpVtbl; - - public int GetType(int obj) - {{ - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public new int GetType() - {{ - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int objA, int objB) - {{ - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public partial struct Vtbl - {{ - [NativeTypeName(""int (int){nativeCallConv}"")] - public new delegate* unmanaged[Thiscall] GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType1; - - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct : MyStruct.Interface - {{ - public Vtbl* lpVtbl; - - public int GetType(int obj) - {{ - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public new int GetType() - {{ - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int objA, int objB) - {{ - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public interface Interface - {{ - int GetType(int obj); - - int GetType(); - - int GetType(int objA, int objB); - }} - - public partial struct Vtbl - where TSelf : unmanaged, Interface - {{ - [NativeTypeName(""int (int){nativeCallConv}"")] - public new delegate* unmanaged[Thiscall] GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType1; - - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(); - - public static int MyInt32Method() - {{ - return 0; - }} - - public static void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - public void MyVoidMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int MyInt32Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public void* MyVoidStarMethod() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - [VtblIndex(0)] - public void MyVoidMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(1)] - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(2)] - public int MyInt32Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(3)] - public void* MyVoidStarMethod() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/DeprecatedToObsoleteTest.cs deleted file mode 100644 index 335c8a5c..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,506 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpPreviewUnix_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - [Obsolete] - MyEnum_Value1, - [Obsolete(""This is obsolete."")] - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum0 - { - MyEnum_Value0, - } - - [Obsolete] - public enum MyEnum1 - { - MyEnum_Value1, - } - - [Obsolete(""This is obsolete."")] - public enum MyEnum2 - { - MyEnum_Value2, - } - - public enum MyEnum3 - { - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable0 = 0; - - [Obsolete] - public static {expectedManagedType} MyVariable1 = 0; - - [Obsolete(""This is obsolete."")] - public static {expectedManagedType} MyVariable2 = 0; - - public static {expectedManagedType} MyVariable3 = 0; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction0() - { - } - - [Obsolete] - public static void MyFunction1() - { - } - - [Obsolete(""This is obsolete."")] - public static void MyFunction2() - { - } - - public static void MyFunction3() - { - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public int MyFunction0() - {{ - return 0; - }} - - [Obsolete] - public int MyFunction1() - {{ - return 0; - }} - - [Obsolete(""This is obsolete."")] - public int MyFunction2() - {{ - return 0; - }} - - public int MyFunction3() - {{ - return 0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct0 - { - [NativeTypeName(""Callback0"")] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct1 - { - [NativeTypeName(""Callback1"")] - [Obsolete] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct2 - { - [NativeTypeName(""Callback2"")] - [Obsolete(""This is obsolete."")] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct3 - { - [NativeTypeName(""Callback3"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction0(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete] - public static extern void MyFunction1(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete(""This is obsolete."")] - public static extern void MyFunction2(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction3(); - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/DigitsSeparatorTest.cs deleted file mode 100644 index 17dd8cc7..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/DigitsSeparatorTest.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.CSharpPreviewUnix; - -[Platform("unix")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyClass - {{ - [NativeTypeName(""const {type}"")] - private const {type} x = {expectedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs deleted file mode 100644 index 374662e5..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/EnumDeclarationTest.cs +++ /dev/null @@ -1,611 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpPreviewUnix_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - [NativeTypeName(""{nativeType}"")] - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum1 : int -{ - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, -} MyEnum1; - -namespace Namespace1 -{ - namespace Namespace2 - { - typedef enum _MyEnum2 : int - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } MyEnum2; - - typedef enum _MyEnum3 : int - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } MyEnum3; - - typedef enum _MyEnum4 : int - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } MyEnum4; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, - } - - public enum MyEnum2 - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } - - public enum MyEnum3 - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } - - public enum MyEnum4 - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } -} -"; - - var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - [Flags] - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = 1, - } -} -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using System; -using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0 = (int)(MyEnum)(10), - MyEnum_Value1 = (int)(MyEnum)(MyEnum_Value0), - MyEnum_Value2 = ((int)(MyEnum)(10)) + MyEnum_Value1, - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0 = 10, - } - - public enum MyEnum2 - { - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (int)(MyEnum1)(10), - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = unchecked((int)(0x80000000)), - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, - } -} -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum1 : uint - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.Methods; - -namespace ClangSharp.Test -{ - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } - - public static partial class Methods - { - public const uint MyEnum1_Value1 = 1; - } -} -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public const uint MyEnum1_Value1 = 1; - - [NativeTypeName(""const int"")] - public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; - } -} -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index 7c0507bb..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,1781 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpPreviewUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* pData, int index) - { - return pData[index]; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(bool x, bool y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - break; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction() - { - } - - public static void MyFunction() - { - MyCalledFunction(); - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction(int x, int y) - { - } - - public static void MyFunction() - { - MyCalledFunction(0, 1); - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 2: - case 3: - { - return 5; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } - - public static partial class Methods - { - public static int MyFunction(MyEnum x) - { - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - return condition ? lhs : rhs; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - continue; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction([NativeTypeName(""const void *"")] void* input) - { - return input; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStructA - {{ - public void** lpVtbl; - - public void MyMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); - }} - }} - - [NativeTypeName(""struct MyStructB : MyStructA"")] - public unsafe partial struct MyStructB - {{ - public void** lpVtbl; - - public void MyMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); - }} - }} - - public static unsafe partial class Methods - {{ - public static MyStructB* MyFunction(MyStructA* input) - {{ - return (MyStructB*)(input); - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - int x = 0; - int y = 1, z = 2; - - return x + y + z; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - - return rhs; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition1, int a, int b, bool condition2, int c) - { - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public float x; - - public float y; - - public float z; - - public float w; - } - - public static partial class Methods - { - public static MyStruct MyFunction1() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - } - - public static MyStruct MyFunction2() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static int MyFunction1(MyStruct instance) - { - return instance.value; - } - - public static int MyFunction2(MyStruct* instance) - { - return instance->value; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static bool MyFunction([NativeTypeName(""const MyStruct &"")] MyStruct* lhs, [NativeTypeName(""const MyStruct &"")] MyStruct* rhs) - { - return lhs->value == rhs->value; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction() - { - return null; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static double MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static float MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - return; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int a - { - get - { - return ref Anonymous.a; - } - } - - public partial struct _Anonymous_e__Struct - { - public int a; - } - } - - public static partial class Methods - { - public static void MyFunction() - { - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public double r; - - public double g; - - public double b; - } - - public static partial class Methods - { - public static MyStruct MyFunction() - { - MyStruct myStruct = new MyStruct(); - - return myStruct; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(int value) - { - return &value; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* value) - { - return *value; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static bool MyFunction(bool value) - { - return !value; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return value{opcode}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return {opcode}value; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index 98c598ff..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,411 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpPreviewUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""const float[4]"")] float* color); - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""void (*)()"")] delegate* unmanaged[Cdecl] callback); - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyFunction(); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeAttr ? $@"[NativeTypeName(""MyTemplate<{nativeType}>"")] " : "")}MyTemplate<{expectedManagedType}> myStruct); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTemplate"")] - public MyTemplate a; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport("""", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeNameAttr ? $@"[NativeTypeName(""{nativeType}"")] " : "")}{expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.StdCall, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [SourceLocation(""ClangUnsavedFile.h"", 1, 17)] - public static extern void MyFunction([SourceLocation(""ClangUnsavedFile.h"", 1, 34)] float value); - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionPointerDeclarationTest.cs deleted file mode 100644 index b37a7dc9..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpPreviewUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public delegate* unmanaged[Stdcall] _callback; - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback *"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs deleted file mode 100644 index 4e438509..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/StructDeclarationTest.cs +++ /dev/null @@ -1,2081 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpPreviewUnix_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[]"")] - public _x_e__FixedBuffer x; - - public partial struct _x_e__FixedBuffer - {{ - public {expectedManagedType} e0; - - [UnscopedRef] - public ref {expectedManagedType} this[int index] - {{ - get - {{ - return ref Unsafe.Add(ref e0, index); - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - readonly get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - readonly get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - readonly get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - readonly get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - [NativeTypeName(""unsigned char : 1"")] - public byte o4_b22_1 - { - readonly get - { - return (byte)((_bitfield2 >> 22) & 0x1u); - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b23_1 - { - readonly get - { - return (int)(_bitfield2 << 8) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b24_1 - { - readonly get - { - return (int)(_bitfield2 << 7) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - } - } - } - - public partial struct MyStruct2 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - readonly get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - readonly get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - [NativeBitfield(""o0_b0_24"", offset: 0, length: 24)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - readonly get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - [NativeBitfield(""o4_b0_16"", offset: 0, length: 16)] - [NativeBitfield(""o4_b16_3"", offset: 16, length: 3)] - [NativeBitfield(""o4_b19_3"", offset: 19, length: 3)] - [NativeBitfield(""o4_b22_1"", offset: 22, length: 1)] - [NativeBitfield(""o4_b23_1"", offset: 23, length: 1)] - [NativeBitfield(""o4_b24_1"", offset: 24, length: 1)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - readonly get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - readonly get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - readonly get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - [NativeTypeName(""unsigned char : 1"")] - public byte o4_b22_1 - { - readonly get - { - return (byte)((_bitfield2 >> 22) & 0x1u); - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b23_1 - { - readonly get - { - return (int)(_bitfield2 << 8) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - } - } - - [NativeTypeName(""int : 1"")] - public int o4_b24_1 - { - readonly get - { - return (int)(_bitfield2 << 7) >> 31; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - } - } - } - - public partial struct MyStruct2 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - [NativeBitfield(""o8_b0_1"", offset: 0, length: 1)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - readonly get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - [NativeBitfield(""o0_b1_1"", offset: 1, length: 1)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - readonly get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""decltype(&MyFunction)"")] - public delegate* unmanaged[Cdecl] _callback; - } - - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyStruct1 - {{ - public int x; - }} - - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyStruct2 - {{ - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyStruct1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyStruct2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - [NativeInheritance(""MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - struct - {{ - {nativeType} value1; - - struct - {{ - {nativeType} value; - }}; - }}; - - union - {{ - {nativeType} value2; - }}; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - public partial struct MyStruct - {{ - public {expectedManagedType} x; - - public {expectedManagedType} y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref {expectedManagedType} z - {{ - get - {{ - return ref Anonymous.z; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._w_e__Struct w - {{ - get - {{ - return ref Anonymous.w; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value1 - {{ - get - {{ - return ref Anonymous.Anonymous1.value1; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value - {{ - get - {{ - return ref Anonymous.Anonymous1.Anonymous.value; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value2 - {{ - get - {{ - return ref Anonymous.Anonymous2.value2; - }} - }} - - [UnscopedRef] - public ref MyUnion u - {{ - get - {{ - return ref Anonymous.u; - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> buffer1 - {{ - get - {{ - return Anonymous.buffer1; - }} - }} - - [UnscopedRef] - public Span buffer2 - {{ - get - {{ - return Anonymous.buffer2; - }} - }} - - public partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C9"")] - public _w_e__Struct w; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L19_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L29_C9"")] - public _Anonymous2_e__Union Anonymous2; - - public MyUnion u; - - [NativeTypeName(""{nativeType}[4]"")] - public _buffer1_e__FixedBuffer buffer1; - - [NativeTypeName(""MyUnion[4]"")] - public _buffer2_e__FixedBuffer buffer2; - - public partial struct _w_e__Struct - {{ - public {expectedManagedType} value; - }} - - public partial struct _Anonymous1_e__Struct - {{ - public {expectedManagedType} value1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L23_C13"")] - public _Anonymous_e__Struct Anonymous; - - public partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} value; - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous2_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} value2; - }} - - [InlineArray(4)] - public partial struct _buffer1_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - - [InlineArray(4)] - public partial struct _buffer2_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int x; - - public int y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int z - { - get - { - return ref Anonymous.z; - } - } - - [UnscopedRef] - public ref int w - { - get - { - return ref Anonymous.Anonymous1.w; - } - } - - public int o0_b0_16 - { - readonly get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - readonly get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - public partial struct _Anonymous_e__Struct - { - public int z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - public partial struct _Anonymous1_e__Struct - { - public int w; - - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - readonly get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - readonly get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public new int Equals; - - public int Dispose; - - public new int GetHashCode; - - public new int GetType; - - public new int MemberwiseClone; - - public new int ReferenceEquals; - - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var usingStatement = "using System.Runtime.InteropServices;\n\n"; - var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; - - if (!Environment.Is64BitProcess) - { - usingStatement = string.Empty; - packing = string.Empty; - } - - var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct1 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} - -{packing} public unsafe partial struct MyStruct2 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - [NativeTypeName(""example_t *"")] - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public double r; - - public double g; - - public double b; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref double a - { - get - { - return ref Anonymous.a; - } - } - - public partial struct _Anonymous_e__Struct - { - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public void MyMethod() - { - } - } - - [NativeTypeName(""struct MyStruct1B : MyStruct1A"")] - public partial struct MyStruct1B - { - public void MyMethod() - { - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - internal partial struct MyStruct1 - { - private int Field1; - - public int Field2; - } - - internal partial struct MyStruct2 - { - private int Field1; - - public int Field2; - } - - public partial struct MyStruct3 - { - private int Field1; - - internal int Field2; - } -} -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"typedef int size_t; - -struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] - public partial struct MyStruct - { - [NativeTypeName(""size_t[2]"")] - public _FixedBuffer_e__FixedBuffer FixedBuffer; - - [InlineArray(2)] - public partial struct _FixedBuffer_e__FixedBuffer - { - public nuint e0; - } - } -} -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @"namespace ClangSharp.Test -{ - [SourceLocation(""ClangUnsavedFile.h"", 1, 8)] - public partial struct MyStruct - { - [SourceLocation(""ClangUnsavedFile.h"", 3, 9)] - public int r; - - [SourceLocation(""ClangUnsavedFile.h"", 4, 9)] - public int g; - - [SourceLocation(""ClangUnsavedFile.h"", 5, 9)] - public int b; - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct;"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{ - public partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [NativeTypeName(""struct (anonymous struct at ClangUnsavedFile.h:4:5)[2]"")] - public _MyArray_e__FixedBuffer MyArray; - - [UnscopedRef] - public ref int First - { - get - { - return ref Anonymous.First; - } - } - - public partial struct _Anonymous_e__Struct - { - public int First; - } - - public partial struct _MyArray_e__Struct - { - public int Second; - } - - [InlineArray(2)] - public partial struct _MyArray_e__FixedBuffer - { - public _MyArray_e__Struct e0; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct;"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int Value1 - { - get - { - return ref Anonymous.Anonymous1.Anonymous2.Value1; - } - } - - [UnscopedRef] - public ref int Value2 - { - get - { - return ref Anonymous.Anonymous1.Anonymous3.Value2; - } - } - - public partial struct _Anonymous_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C14"")] - public _Anonymous1_e__Struct Anonymous1; - - public partial struct _Anonymous1_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C9"")] - public _Anonymous2_e__Struct Anonymous2; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L5_C9"")] - public _Anonymous3_e__Struct Anonymous3; - - public partial struct _Anonymous2_e__Struct - { - public int Value1; - } - - public partial struct _Anonymous3_e__Struct - { - public int Value2; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs deleted file mode 100644 index 4d0ae17f..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/UnionDeclarationTest.cs +++ /dev/null @@ -1,1513 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpPreviewUnix_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - {{ - readonly get - {{ - return _bitfield1 & 0xFFFFFFu; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - }} - }} - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - {{ - readonly get - {{ - return _bitfield2 & 0xFFFFu; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - }} - }} - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - {{ - readonly get - {{ - return (_bitfield2 >> 16) & 0x7u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - }} - }} - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - {{ - readonly get - {{ - return (int)(_bitfield2 << 10) >> 29; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - }} - }} - - [NativeTypeName(""unsigned char : 1"")] - public byte o4_b22_1 - {{ - readonly get - {{ - return (byte)((_bitfield2 >> 22) & 0x1u); - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - }} - }} - - [NativeTypeName(""int : 1"")] - public int o4_b23_1 - {{ - readonly get - {{ - return (int)(_bitfield2 << 8) >> 31; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - }} - }} - - [NativeTypeName(""int : 1"")] - public int o4_b24_1 - {{ - readonly get - {{ - return (int)(_bitfield2 << 7) >> 31; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - readonly get - {{ - return _bitfield1 & 0x1u; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - }} - }} - - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - {{ - readonly get - {{ - return _bitfield2 & 0x1u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion3 - {{ - [FieldOffset(0)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - readonly get - {{ - return _bitfield & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - }} - }} - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - {{ - readonly get - {{ - return (_bitfield >> 1) & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public int x; - }} - - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyUnion1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyUnion2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref {expectedManagedType} a - {{ - get - {{ - return ref Anonymous.a; - }} - }} - - [UnscopedRef] - public ref MyStruct s - {{ - get - {{ - return ref Anonymous.s; - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> buffer - {{ - get - {{ - return Anonymous.buffer; - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} a; - - [FieldOffset(0)] - public MyStruct s; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[4]"")] - public _buffer_e__FixedBuffer buffer; - - [InlineArray(4)] - public partial struct _buffer_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public int y; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref int z - { - get - { - return ref Anonymous.z; - } - } - - [UnscopedRef] - public ref int w - { - get - { - return ref Anonymous.Anonymous1.w; - } - } - - public int o0_b0_16 - { - readonly get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - readonly get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public int z; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Union Anonymous1; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous1_e__Union - { - [FieldOffset(0)] - public int w; - - [FieldOffset(0)] - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - readonly get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - readonly get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public new int Equals; - - [FieldOffset(0)] - public int Dispose; - - [FieldOffset(0)] - public new int GetHashCode; - - [FieldOffset(0)] - public new int GetType; - - [FieldOffset(0)] - public new int MemberwiseClone; - - [FieldOffset(0)] - public new int ReferenceEquals; - - [FieldOffset(0)] - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - [NativeTypeName(""example_t *"")] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - public double r; - - [FieldOffset(0)] - public double g; - - [FieldOffset(0)] - public double b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref double a - { - get - { - return ref Anonymous.a; - } - } - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - } -} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@"using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct _MY_UNION - {{ - [FieldOffset(0)] - [NativeTypeName(""long[2]"")] - public _AsArray_e__FixedBuffer AsArray; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref nint First - {{ - get - {{ - return ref Anonymous.First; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A - {{ - get - {{ - return ref Anonymous.Anonymous.A; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B - {{ - get - {{ - return ref Anonymous.Anonymous.B; - }} - }} - - public partial struct _Anonymous_e__Struct - {{ - [NativeTypeName(""long"")] - public nint First; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C9"")] - public _Anonymous_e__Union Anonymous; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L9_C13"")] - public _A_e__Struct A; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C13"")] - public _B_e__Struct B; - - public partial struct _A_e__Struct - {{ - [NativeTypeName(""long"")] - public nint Second; - }} - - public partial struct _B_e__Struct - {{ - [NativeTypeName(""long"")] - public nint Second; - }} - }} - }} - - [InlineArray(2)] - public partial struct _AsArray_e__FixedBuffer - {{ - public nint e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs deleted file mode 100644 index 3b4edf2f..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewUnix/VarDeclarationTest.cs +++ /dev/null @@ -1,412 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class CSharpPreviewUnix_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""{nativeType}"")] - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const GUID"")] - public static readonly Guid IID_IUnknown = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - }} -}} -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 {nativeValue}"")] - public const {expectedManagedType} MyMacro1 = {expectedManagedValue}; - - [NativeTypeName(""#define MyMacro2 MyMacro1"")] - public const {expectedManagedType} MyMacro2 = {expectedManagedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 0 + \\\n1"")] - public const int MyMacro1 = 0 + 1; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] - public static ReadOnlySpan MyMacro1 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] - public const string MyMacro1 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; - - [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; - - [NativeTypeName(""const wchar_t *const"")] - public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public static ReadOnlySpan MyConst1 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; - - [NativeTypeName(""const wchar_t *"")] - public static uint[] MyConst2 = [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; - - [NativeTypeName(""const wchar_t *const"")] - public static ReadOnlySpan MyConst3 => [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000]; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 (long)0x80000000L"")] - public static readonly nint MyMacro1 = unchecked((nint)(0x80000000)); - - [NativeTypeName(""#define MyMacro2 (int)0x80000000"")] - public const int MyMacro2 = unchecked((int)(0x80000000)); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 unsigned(-1)"")] - public const uint MyMacro1 = unchecked((uint)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro3 MyMacro2(3)"")] - public const int MyMacro3 = unchecked((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 ((int*) -1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 reinterpret_cast(-1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const int[2][2]"")] - public static readonly int[][] MyArray = new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }}; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"")] - public const int ADDRESS_IN_USE = unchecked((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))); - }} -}} -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpPreviewUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs deleted file mode 100644 index 0f1641a6..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,419 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpPreviewWindows_CXXMethodDeclarationTest : CXXMethodDeclarationCSharpTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [NativeTypeName(""struct MyStruct : MyTemplate"")] - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern int* DoWork(MyStruct* pThis, int* value = null); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = Environment.Is64BitProcess - ? "?MyVoidMethod@MyStruct@@QEAAXXZ" - : "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.ThisCall, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(MyStruct* pThis); - - public int MyInt32Method() - {{ - return 0; - }} - - public void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - public int GetType(int objA, int objB) - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public new int GetType() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int obj) - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public Vtbl* lpVtbl; - - public int GetType(int objA, int objB) - {{ - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public new int GetType() - {{ - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int obj) - {{ - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public partial struct Vtbl - {{ - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public new delegate* unmanaged[Thiscall] GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType1; - - [NativeTypeName(""int (int){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct : MyStruct.Interface - {{ - public Vtbl* lpVtbl; - - public int GetType(int objA, int objB) - {{ - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - }} - - public new int GetType() - {{ - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int GetType(int obj) - {{ - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); - }} - - public interface Interface - {{ - int GetType(int objA, int objB); - - int GetType(); - - int GetType(int obj); - }} - - public partial struct Vtbl - where TSelf : unmanaged, Interface - {{ - [NativeTypeName(""int (int, int){nativeCallConv}"")] - public new delegate* unmanaged[Thiscall] GetType; - - [NativeTypeName(""int (){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType1; - - [NativeTypeName(""int (int){nativeCallConv}"")] - public delegate* unmanaged[Thiscall] GetType2; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyVoidMethod(); - - public static int MyInt32Method() - {{ - return 0; - }} - - public static void* MyVoidStarMethod() - {{ - return null; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - public void MyVoidMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public int MyInt32Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - public void* MyVoidStarMethod() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct - {{ - public void** lpVtbl; - - [VtblIndex(0)] - public void MyVoidMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(1)] - [return: NativeTypeName(""signed char"")] - public sbyte MyInt8Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(2)] - public int MyInt32Method() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - - [VtblIndex(3)] - public void* MyVoidStarMethod() - {{ - return ((delegate* unmanaged[Thiscall])(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/DeprecatedToObsoleteTest.cs deleted file mode 100644 index b18e9ae2..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,506 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpPreviewWindows_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - [Obsolete] - public {expectedManagedType} g; - - [Obsolete(""This is obsolete."")] - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} -}} -"; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct0 - {{ - public int r; - }} - - [Obsolete] - public partial struct MyStruct1 - {{ - public int r; - }} - - [Obsolete(""This is obsolete."")] - public partial struct MyStruct2 - {{ - public int r; - }} - - public partial struct MyStruct3 - {{ - public int r; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - [Obsolete] - MyEnum_Value1, - [Obsolete(""This is obsolete."")] - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public enum MyEnum0 - { - MyEnum_Value0, - } - - [Obsolete] - public enum MyEnum1 - { - MyEnum_Value1, - } - - [Obsolete(""This is obsolete."")] - public enum MyEnum2 - { - MyEnum_Value2, - } - - public enum MyEnum3 - { - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable0 = 0; - - [Obsolete] - public static {expectedManagedType} MyVariable1 = 0; - - [Obsolete(""This is obsolete."")] - public static {expectedManagedType} MyVariable2 = 0; - - public static {expectedManagedType} MyVariable3 = 0; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction0() - { - } - - [Obsolete] - public static void MyFunction1() - { - } - - [Obsolete(""This is obsolete."")] - public static void MyFunction2() - { - } - - public static void MyFunction3() - { - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public int MyFunction0() - {{ - return 0; - }} - - [Obsolete] - public int MyFunction1() - {{ - return 0; - }} - - [Obsolete(""This is obsolete."")] - public int MyFunction2() - {{ - return 0; - }} - - public int MyFunction3() - {{ - return 0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct0 - { - [NativeTypeName(""Callback0"")] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct1 - { - [NativeTypeName(""Callback1"")] - [Obsolete] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct2 - { - [NativeTypeName(""Callback2"")] - [Obsolete(""This is obsolete."")] - public delegate* unmanaged[Cdecl] _callback; - } - - public unsafe partial struct MyStruct3 - { - [NativeTypeName(""Callback3"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction0(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete] - public static extern void MyFunction1(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete(""This is obsolete."")] - public static extern void MyFunction2(); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction3(); - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/DigitsSeparatorTest.cs deleted file mode 100644 index 191823be..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/DigitsSeparatorTest.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.CSharpPreviewWindows; - -[Platform("win")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyClass - {{ - [NativeTypeName(""const {type}"")] - private const {type} x = {expectedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs deleted file mode 100644 index b1322b9f..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/EnumDeclarationTest.cs +++ /dev/null @@ -1,611 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpPreviewWindows_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - [NativeTypeName(""{nativeType}"")] - public enum MyEnum : {expectedManagedType} - {{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum1 : int -{ - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, -} MyEnum1; - -namespace Namespace1 -{ - namespace Namespace2 - { - typedef enum _MyEnum2 : int - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } MyEnum2; - - typedef enum _MyEnum3 : int - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } MyEnum3; - - typedef enum _MyEnum4 : int - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } MyEnum4; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1, - MyEnum1_Value2, - MyEnum1_Value3, - } - - public enum MyEnum2 - { - MyEnum2_Value1, - MyEnum2_Value2, - MyEnum2_Value3, - } - - public enum MyEnum3 - { - MyEnum3_Value1, - MyEnum3_Value2, - MyEnum3_Value3, - } - - public enum MyEnum4 - { - MyEnum4_Value1, - MyEnum4_Value2, - MyEnum4_Value3, - } -} -"; - - var remappedNames = new Dictionary { ["_MyEnum1"] = "MyEnum1", ["Namespace1.Namespace2._MyEnum2"] = "MyEnum2", ["_MyEnum3"] = "MyEnum3", ["Namespace1::Namespace2::_MyEnum4"] = "MyEnum4" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @"using System; - -namespace ClangSharp.Test -{ - [Flags] - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = 1, - } -} -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using System; -using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value1 = 1, - } - - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } -} -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0 = (int)(MyEnum)(10), - MyEnum_Value1 = (int)(MyEnum)(MyEnum_Value0), - MyEnum_Value2 = ((int)(MyEnum)(10)) + MyEnum_Value1, - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum1; - -namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0 = 10, - } - - public enum MyEnum2 - { - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (int)(MyEnum1)(10), - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = unchecked((int)(0x80000000)), - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } -} -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, - } -} -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""int"")] - public enum MyEnum1 : uint - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum1 - { - MyEnum1_Value0, - } - - [NativeTypeName(""int"")] - public enum MyEnum2 : uint - { - MyEnum2_Value0, - } -} -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @"using static ClangSharp.Test.Methods; - -namespace ClangSharp.Test -{ - public enum MyEnum2 - { - MyEnum2_Value1 = MyEnum1_Value1, - } - - public static partial class Methods - { - public const int MyEnum1_Value1 = 1; - } -} -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public const int MyEnum1_Value1 = 1; - - [NativeTypeName(""const int"")] - public const int MyEnum2_Value1 = (int)(MyEnum1_Value1) + 1; - } -} -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index d6502c71..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,1781 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpPreviewWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* pData, int index) - { - return pData[index]; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(int x, int y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction(bool x, bool y) - {{ - return x {opcode} y; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - break; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction() - { - } - - public static void MyFunction() - { - MyCalledFunction(); - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyCalledFunction(int x, int y) - { - } - - public static void MyFunction() - { - MyCalledFunction(0, 1); - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - case 0: - { - return 0; - } - - case 2: - case 3: - { - return 5; - } - } - - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = @"using static ClangSharp.Test.MyEnum; - -namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } - - public static partial class Methods - { - public static int MyFunction(MyEnum x) - { - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - return condition ? lhs : rhs; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - while (true) - { - continue; - } - - return 0; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(float input) - { - return (int)(input); - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction([NativeTypeName(""const void *"")] void* input) - { - return input; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public unsafe partial struct MyStructA - {{ - public void** lpVtbl; - - public void MyMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); - }} - }} - - [NativeTypeName(""struct MyStructB : MyStructA"")] - public unsafe partial struct MyStructB - {{ - public void** lpVtbl; - - public void MyMethod() - {{ - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); - }} - }} - - public static unsafe partial class Methods - {{ - public static MyStructB* MyFunction(MyStructA* input) - {{ - return (MyStructB*)(input); - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(void* input) - { - return (int*)(input); - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - int x = 0; - int y = 1, z = 2; - - return x + y + z; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - - return rhs; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition1, int a, int b, bool condition2, int c) - { - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(bool condition, int lhs, int rhs) - { - if (condition) - { - return lhs; - } - else - { - return rhs; - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public float x; - - public float y; - - public float z; - - public float w; - } - - public static partial class Methods - { - public static MyStruct MyFunction1() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - } - - public static MyStruct MyFunction2() - { - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static int MyFunction1(MyStruct instance) - { - return instance.value; - } - - public static int MyFunction2(MyStruct* instance) - { - return instance->value; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public static unsafe partial class Methods - { - public static bool MyFunction([NativeTypeName(""const MyStruct &"")] MyStruct* lhs, [NativeTypeName(""const MyStruct &"")] MyStruct* rhs) - { - return lhs->value == rhs->value; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction() - { - return null; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static bool MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static double MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static float MyFunction() - {{ - return {value}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static void MyFunction() - { - return; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction() - { - return -1; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int a - { - get - { - return ref Anonymous.a; - } - } - - public partial struct _Anonymous_e__Struct - { - public int a; - } - } - - public static partial class Methods - { - public static void MyFunction() - { - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public double r; - - public double g; - - public double b; - } - - public static partial class Methods - { - public static MyStruct MyFunction() - { - MyStruct myStruct = new MyStruct(); - - return myStruct; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int value) - { - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int* MyFunction(int value) - { - return &value; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static int MyFunction(int* value) - { - return *value; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static bool MyFunction(bool value) - { - return !value; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return value{opcode}; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static int MyFunction(int value) - {{ - return {opcode}value; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - public static int MyFunction(int count) - { - int i = 0; - - while (i < count) - { - i++; - } - - return i; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index 2ebba7ad..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,428 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpPreviewWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""const float[4]"")] float* color); - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""void (*)()"")] delegate* unmanaged[Cdecl] callback); - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, EntryPoint = ""{entryPoint}"", ExactSpelling = true)] - public static extern void MyFunction(); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@"{expectedUsingStatement}using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeAttr ? $@"[NativeTypeName(""MyTemplate<{nativeType}>"")] " : "")}MyTemplate<{expectedManagedType}> myStruct); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTemplate"")] - public MyTemplate a; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport("""", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({(expectedNativeTypeNameAttr ? $@"[NativeTypeName(""{nativeType}"")] " : "")}{expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction({expectedManagedType} value = {expectedManagedInit}); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", ExactSpelling = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.StdCall, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction1(int value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, SetLastError = true)] - public static extern void MyFunction2(int value); - } -} -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [SourceLocation(""ClangUnsavedFile.h"", 1, 17)] - public static extern void MyFunction([SourceLocation(""ClangUnsavedFile.h"", 1, 34)] float value); - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(int value, ...);"; - - const string ExpectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(int value, __arglist); - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionPointerDeclarationTest.cs deleted file mode 100644 index 35e7a5c2..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpPreviewWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback"")] - public delegate* unmanaged[Stdcall] _callback; - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""Callback *"")] - public delegate* unmanaged[Cdecl] _callback; - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs deleted file mode 100644 index d3e05c78..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/StructDeclarationTest.cs +++ /dev/null @@ -1,2087 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpPreviewWindows_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[]"")] - public _x_e__FixedBuffer x; - - public partial struct _x_e__FixedBuffer - {{ - public {expectedManagedType} e0; - - [UnscopedRef] - public ref {expectedManagedType} this[int index] - {{ - get - {{ - return ref Unsafe.Add(ref e0, index); - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> AsSpan(int length) => MemoryMarshal.CreateSpan(ref e0, length); - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - readonly get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - readonly get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - readonly get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - readonly get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - public byte _bitfield3; - - [NativeTypeName(""unsigned char : 1"")] - public byte o8_b0_1 - { - readonly get - { - return (byte)(_bitfield3 & 0x1u); - } - - set - { - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - } - } - - public int _bitfield4; - - [NativeTypeName(""int : 1"")] - public int o12_b0_1 - { - readonly get - { - return (_bitfield4 << 31) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - } - } - - [NativeTypeName(""int : 1"")] - public int o12_b1_1 - { - readonly get - { - return (_bitfield4 << 30) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - } - } - } - - public partial struct MyStruct2 - { - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - readonly get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - readonly get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1 - { - [NativeBitfield(""o0_b0_24"", offset: 0, length: 24)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - { - readonly get - { - return _bitfield1 & 0xFFFFFFu; - } - - set - { - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - } - } - - [NativeBitfield(""o4_b0_16"", offset: 0, length: 16)] - [NativeBitfield(""o4_b16_3"", offset: 16, length: 3)] - [NativeBitfield(""o4_b19_3"", offset: 19, length: 3)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - { - readonly get - { - return _bitfield2 & 0xFFFFu; - } - - set - { - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - } - } - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - { - readonly get - { - return (_bitfield2 >> 16) & 0x7u; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - } - } - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - { - readonly get - { - return (int)(_bitfield2 << 10) >> 29; - } - - set - { - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - } - } - - [NativeBitfield(""o8_b0_1"", offset: 0, length: 1)] - public byte _bitfield3; - - [NativeTypeName(""unsigned char : 1"")] - public byte o8_b0_1 - { - readonly get - { - return (byte)(_bitfield3 & 0x1u); - } - - set - { - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - } - } - - [NativeBitfield(""o12_b0_1"", offset: 0, length: 1)] - [NativeBitfield(""o12_b1_1"", offset: 1, length: 1)] - public int _bitfield4; - - [NativeTypeName(""int : 1"")] - public int o12_b0_1 - { - readonly get - { - return (_bitfield4 << 31) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - } - } - - [NativeTypeName(""int : 1"")] - public int o12_b1_1 - { - readonly get - { - return (_bitfield4 << 30) >> 31; - } - - set - { - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - } - } - } - - public partial struct MyStruct2 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield1 & 0x1u; - } - - set - { - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - } - } - - public int x; - - [NativeBitfield(""o8_b0_1"", offset: 0, length: 1)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - { - readonly get - { - return _bitfield2 & 0x1u; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - } - } - } - - public partial struct MyStruct3 - { - [NativeBitfield(""o0_b0_1"", offset: 0, length: 1)] - [NativeBitfield(""o0_b1_1"", offset: 1, length: 1)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - { - readonly get - { - return _bitfield & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - } - } - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - { - readonly get - { - return (_bitfield >> 1) & 0x1u; - } - - set - { - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - [NativeTypeName(""decltype(&MyFunction)"")] - public delegate* unmanaged[Cdecl] _callback; - } - - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } -} -"; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - public partial struct MyOtherStruct - {{ - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyStruct e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyStruct1 - {{ - public int x; - }} - - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyStruct2 - {{ - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyStruct1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyStruct2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public int x; - - public int y; - } - - public partial struct MyStruct1B - { - public int x; - - public int y; - } - - [NativeTypeName(""struct MyStruct2 : MyStruct1A, MyStruct1B"")] - [NativeInheritance(""MyStruct1B"")] - public partial struct MyStruct2 - { - public MyStruct1A Base1; - - public MyStruct1B Base2; - - public int z; - - public int w; - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - struct - {{ - {nativeType} value1; - - struct - {{ - {nativeType} value; - }}; - }}; - - union - {{ - {nativeType} value2; - }}; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - public partial struct MyStruct - {{ - public {expectedManagedType} x; - - public {expectedManagedType} y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref {expectedManagedType} z - {{ - get - {{ - return ref Anonymous.z; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._w_e__Struct w - {{ - get - {{ - return ref Anonymous.w; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value1 - {{ - get - {{ - return ref Anonymous.Anonymous1.value1; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value - {{ - get - {{ - return ref Anonymous.Anonymous1.Anonymous.value; - }} - }} - - [UnscopedRef] - public ref {expectedManagedType} value2 - {{ - get - {{ - return ref Anonymous.Anonymous2.value2; - }} - }} - - [UnscopedRef] - public ref MyUnion u - {{ - get - {{ - return ref Anonymous.u; - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> buffer1 - {{ - get - {{ - return Anonymous.buffer1; - }} - }} - - [UnscopedRef] - public Span buffer2 - {{ - get - {{ - return Anonymous.buffer2; - }} - }} - - public partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C9"")] - public _w_e__Struct w; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L19_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L29_C9"")] - public _Anonymous2_e__Union Anonymous2; - - public MyUnion u; - - [NativeTypeName(""{nativeType}[4]"")] - public _buffer1_e__FixedBuffer buffer1; - - [NativeTypeName(""MyUnion[4]"")] - public _buffer2_e__FixedBuffer buffer2; - - public partial struct _w_e__Struct - {{ - public {expectedManagedType} value; - }} - - public partial struct _Anonymous1_e__Struct - {{ - public {expectedManagedType} value1; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L23_C13"")] - public _Anonymous_e__Struct Anonymous; - - public partial struct _Anonymous_e__Struct - {{ - public {expectedManagedType} value; - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous2_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} value2; - }} - - [InlineArray(4)] - public partial struct _buffer1_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - - [InlineArray(4)] - public partial struct _buffer2_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int x; - - public int y; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int z - { - get - { - return ref Anonymous.z; - } - } - - [UnscopedRef] - public ref int w - { - get - { - return ref Anonymous.Anonymous1.w; - } - } - - public int o0_b0_16 - { - readonly get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - readonly get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - public partial struct _Anonymous_e__Struct - { - public int z; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Struct Anonymous1; - - public partial struct _Anonymous1_e__Struct - { - public int w; - - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - readonly get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - readonly get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - public partial struct MyNestedStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public new int Equals; - - public int Dispose; - - public new int GetHashCode; - - public new int GetType; - - public new int MemberwiseClone; - - public new int ReferenceEquals; - - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var usingStatement = "using System.Runtime.InteropServices;\n\n"; - var packing = " [StructLayout(LayoutKind.Sequential, Pack = 4)]\n"; - - if (!Environment.Is64BitProcess) - { - usingStatement = string.Empty; - packing = string.Empty; - } - - var expectedOutputContents = $@"{usingStatement}namespace ClangSharp.Test -{{ - public unsafe partial struct MyStruct1 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} - -{packing} public unsafe partial struct MyStruct2 - {{ - [NativeTypeName(""unsigned int"")] - public uint Field1; - - public void* Field2; - - [NativeTypeName(""unsigned int"")] - public uint Field3; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public unsafe partial struct example_s - {{ - [NativeTypeName(""example_t *"")] - public example_s* next; - - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public double r; - - public double g; - - public double b; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref double a - { - get - { - return ref Anonymous.a; - } - } - - public partial struct _Anonymous_e__Struct - { - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} r; - - public {expectedManagedType} g; - - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct1A - { - public void MyMethod() - { - } - } - - [NativeTypeName(""struct MyStruct1B : MyStruct1A"")] - public partial struct MyStruct1B - { - public void MyMethod() - { - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - internal partial struct MyStruct1 - { - private int Field1; - - public int Field2; - } - - internal partial struct MyStruct2 - { - private int Field1; - - public int Field2; - } - - public partial struct MyStruct3 - { - private int Field1; - - internal int Field2; - } -} -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Sequential, Pack = CustomPackValue)] - public partial struct MyStruct - { - [NativeTypeName(""size_t[2]"")] - public _FixedBuffer_e__FixedBuffer FixedBuffer; - - [InlineArray(2)] - public partial struct _FixedBuffer_e__FixedBuffer - { - public nuint e0; - } - } -} -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @"namespace ClangSharp.Test -{ - [SourceLocation(""ClangUnsavedFile.h"", 1, 8)] - public partial struct MyStruct - { - [SourceLocation(""ClangUnsavedFile.h"", 3, 9)] - public int r; - - [SourceLocation(""ClangUnsavedFile.h"", 4, 9)] - public int g; - - [SourceLocation(""ClangUnsavedFile.h"", 5, 9)] - public int b; - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct;"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{ - public partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [NativeTypeName(""struct (anonymous struct at ClangUnsavedFile.h:4:5)[2]"")] - public _MyArray_e__FixedBuffer MyArray; - - [UnscopedRef] - public ref int First - { - get - { - return ref Anonymous.First; - } - } - - public partial struct _Anonymous_e__Struct - { - public int First; - } - - public partial struct _MyArray_e__Struct - { - public int Second; - } - - [InlineArray(2)] - public partial struct _MyArray_e__FixedBuffer - { - public _MyArray_e__Struct e0; - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct;"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; - -namespace ClangSharp.Test -{ - public partial struct _MyStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int Value1 - { - get - { - return ref Anonymous.Anonymous1.Anonymous2.Value1; - } - } - - [UnscopedRef] - public ref int Value2 - { - get - { - return ref Anonymous.Anonymous1.Anonymous3.Value2; - } - } - - public partial struct _Anonymous_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L3_C14"")] - public _Anonymous1_e__Struct Anonymous1; - - public partial struct _Anonymous1_e__Struct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C9"")] - public _Anonymous2_e__Struct Anonymous2; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L5_C9"")] - public _Anonymous3_e__Struct Anonymous3; - - public partial struct _Anonymous2_e__Struct - { - public int Value1; - } - - public partial struct _Anonymous3_e__Struct - { - public int Value2; - } - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs deleted file mode 100644 index 1cca78ca..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/UnionDeclarationTest.cs +++ /dev/null @@ -1,1519 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpPreviewWindows_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ", Pack = 1" : ""; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 24"")] - public uint o0_b0_24 - {{ - readonly get - {{ - return _bitfield1 & 0xFFFFFFu; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - }} - }} - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 16"")] - public uint o4_b0_16 - {{ - readonly get - {{ - return _bitfield2 & 0xFFFFu; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - }} - }} - - [NativeTypeName(""unsigned int : 3"")] - public uint o4_b16_3 - {{ - readonly get - {{ - return (_bitfield2 >> 16) & 0x7u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - }} - }} - - [NativeTypeName(""int : 3"")] - public int o4_b19_3 - {{ - readonly get - {{ - return (int)(_bitfield2 << 10) >> 29; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - }} - }} - - [FieldOffset(0)] - public byte _bitfield3; - - [NativeTypeName(""unsigned char : 1"")] - public byte o8_b0_1 - {{ - readonly get - {{ - return (byte)(_bitfield3 & 0x1u); - }} - - set - {{ - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - }} - }} - - [FieldOffset(0)] - public int _bitfield4; - - [NativeTypeName(""int : 1"")] - public int o12_b0_1 - {{ - readonly get - {{ - return (_bitfield4 << 31) >> 31; - }} - - set - {{ - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - }} - }} - - [NativeTypeName(""int : 1"")] - public int o12_b1_1 - {{ - readonly get - {{ - return (_bitfield4 << 30) >> 31; - }} - - set - {{ - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public uint _bitfield1; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - readonly get - {{ - return _bitfield1 & 0x1u; - }} - - set - {{ - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - }} - }} - - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public uint _bitfield2; - - [NativeTypeName(""unsigned int : 1"")] - public uint o8_b0_1 - {{ - readonly get - {{ - return _bitfield2 & 0x1u; - }} - - set - {{ - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - }} - }} - }} - - [StructLayout(LayoutKind.Explicit{expectedPack})] - public partial struct MyUnion3 - {{ - [FieldOffset(0)] - public uint _bitfield; - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b0_1 - {{ - readonly get - {{ - return _bitfield & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - }} - }} - - [NativeTypeName(""unsigned int : 1"")] - public uint o0_b1_1 - {{ - readonly get - {{ - return (_bitfield >> 1) & 0x1u; - }} - - set - {{ - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyOtherUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyUnion[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public MyUnion e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - public unsafe partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - public {expectedManagedType} e1; - public {expectedManagedType} e2; - - public ref {expectedManagedType} this[int index] - {{ - get - {{ - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - }} - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[3]"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[2][1][3][4]"")] - public _c_e__FixedBuffer c; - - [InlineArray(2 * 1 * 3 * 4)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0_0_0_0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyBuffer"")] - public _c_e__FixedBuffer c; - - [InlineArray(3)] - public partial struct _c_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000046"")] - public partial struct MyUnion1 - {{ - [FieldOffset(0)] - public int x; - }} - - [StructLayout(LayoutKind.Explicit)] - [Guid(""00000000-0000-0000-C000-000000000047"")] - public partial struct MyUnion2 - {{ - [FieldOffset(0)] - public int x; - }} - - public static partial class Methods - {{ - public static readonly Guid IID_MyUnion1 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - - public static readonly Guid IID_MyUnion2 = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@"using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - public partial struct MyStruct - {{ - public {expectedManagedType} value; - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L{line}_C{column}"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref {expectedManagedType} a - {{ - get - {{ - return ref Anonymous.a; - }} - }} - - [UnscopedRef] - public ref MyStruct s - {{ - get - {{ - return ref Anonymous.s; - }} - }} - - [UnscopedRef] - public Span<{expectedManagedType}> buffer - {{ - get - {{ - return Anonymous.buffer; - }} - }} - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - public {expectedManagedType} a; - - [FieldOffset(0)] - public MyStruct s; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}[4]"")] - public _buffer_e__FixedBuffer buffer; - - [InlineArray(4)] - public partial struct _buffer_e__FixedBuffer - {{ - public {expectedManagedType} e0; - }} - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - public int x; - - [FieldOffset(0)] - public int y; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L6_C5"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref int z - { - get - { - return ref Anonymous.z; - } - } - - [UnscopedRef] - public ref int w - { - get - { - return ref Anonymous.Anonymous1.w; - } - } - - public int o0_b0_16 - { - readonly get - { - return Anonymous.Anonymous1.o0_b0_16; - } - - set - { - Anonymous.Anonymous1.o0_b0_16 = value; - } - } - - public int o0_b16_4 - { - readonly get - { - return Anonymous.Anonymous1.o0_b16_4; - } - - set - { - Anonymous.Anonymous1.o0_b16_4 = value; - } - } - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public int z; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L10_C9"")] - public _Anonymous1_e__Union Anonymous1; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous1_e__Union - { - [FieldOffset(0)] - public int w; - - [FieldOffset(0)] - public int _bitfield; - - [NativeTypeName(""int : 16"")] - public int o0_b0_16 - { - readonly get - { - return (_bitfield << 16) >> 16; - } - - set - { - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - } - } - - [NativeTypeName(""int : 4"")] - public int o0_b16_4 - { - readonly get - { - return (_bitfield << 12) >> 28; - } - - set - { - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - - [FieldOffset(0)] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [StructLayout(LayoutKind.Explicit)] - public partial struct MyNestedUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} a; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public new int Equals; - - [FieldOffset(0)] - public int Dispose; - - [FieldOffset(0)] - public new int GetHashCode; - - [FieldOffset(0)] - public new int GetType; - - [FieldOffset(0)] - public new int MemberwiseClone; - - [FieldOffset(0)] - public new int ReferenceEquals; - - [FieldOffset(0)] - public new int ToString; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct example_s - {{ - [FieldOffset(0)] - [NativeTypeName(""example_t *"")] - public example_s* next; - - [FieldOffset(0)] - public void* data; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - }} -}} -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @"using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - [FieldOffset(0)] - public double r; - - [FieldOffset(0)] - public double g; - - [FieldOffset(0)] - public double b; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C5"")] - public _Anonymous_e__Union Anonymous; - - [UnscopedRef] - public ref double a - { - get - { - return ref Anonymous.a; - } - } - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - { - [FieldOffset(0)] - public double a; - } - } -} -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - public {expectedManagedType} r; - - [FieldOffset(0)] - public {expectedManagedType} g; - - [FieldOffset(0)] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - { - } -} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""{nativeType}"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct MyUnion - {{ - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} r; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} g; - - [FieldOffset(0)] - [NativeTypeName(""MyTypedefAlias"")] - public {expectedManagedType} b; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@"using System.Diagnostics.CodeAnalysis; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{{ - [StructLayout(LayoutKind.Explicit)] - public partial struct _MY_UNION - {{ - [FieldOffset(0)] - [NativeTypeName(""long[2]"")] - public _AsArray_e__FixedBuffer AsArray; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L4_C5"")] - public _Anonymous_e__Struct Anonymous; - - [UnscopedRef] - public ref int First - {{ - get - {{ - return ref Anonymous.First; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct A - {{ - get - {{ - return ref Anonymous.Anonymous.A; - }} - }} - - [UnscopedRef] - public ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct B - {{ - get - {{ - return ref Anonymous.Anonymous.B; - }} - }} - - public partial struct _Anonymous_e__Struct - {{ - [NativeTypeName(""long"")] - public int First; - - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L7_C9"")] - public _Anonymous_e__Union Anonymous; - - [StructLayout(LayoutKind.Explicit)] - public partial struct _Anonymous_e__Union - {{ - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L9_C13"")] - public _A_e__Struct A; - - [FieldOffset(0)] - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C13"")] - public _B_e__Struct B; - - public partial struct _A_e__Struct - {{ - [NativeTypeName(""long"")] - public int Second; - }} - - public partial struct _B_e__Struct - {{ - [NativeTypeName(""long"")] - public int Second; - }} - }} - }} - - [InlineArray(2)] - public partial struct _AsArray_e__FixedBuffer - {{ - public int e0; - }} - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs deleted file mode 100644 index 7e6e6028..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CSharpPreviewWindows/VarDeclarationTest.cs +++ /dev/null @@ -1,408 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class CSharpPreviewWindows_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""{nativeType}"")] - public static {expectedManagedType} MyVariable = 0; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const GUID"")] - public static readonly Guid IID_IUnknown = new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); - }} -}} -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 {nativeValue}"")] - public const {expectedManagedType} MyMacro1 = {expectedManagedValue}; - - [NativeTypeName(""#define MyMacro2 MyMacro1"")] - public const {expectedManagedType} MyMacro2 = {expectedManagedValue}; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 0 + \\\n1"")] - public const int MyMacro1 = 0 + 1; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 \""Test\0\\\r\n\t\""\"""")] - public static ReadOnlySpan MyMacro1 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 u\""Test\0\\\r\n\t\""\"""")] - public const string MyMacro1 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public const string MyConst1 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const wchar_t[11]"")] - public const string MyConst1 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *"")] - public static string MyConst2 = ""Test\0\\\r\n\t\""""; - - [NativeTypeName(""const wchar_t *const"")] - public const string MyConst3 = ""Test\0\\\r\n\t\""""; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@"using System; - -namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const char[11]"")] - public static ReadOnlySpan MyConst1 => ""Test\0\\\r\n\t\""""u8; - - [NativeTypeName(""const char *"")] - public static byte[] MyConst2 = ""Test\0\\\r\n\t\""""u8.ToArray(); - - [NativeTypeName(""const char *const"")] - public static ReadOnlySpan MyConst3 => ""Test\0\\\r\n\t\""""u8; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 (long)0x80000000L"")] - public const int MyMacro1 = unchecked((int)(0x80000000)); - - [NativeTypeName(""#define MyMacro2 (int)0x80000000"")] - public const int MyMacro2 = unchecked((int)(0x80000000)); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro1 unsigned(-1)"")] - public const uint MyMacro1 = unchecked((uint)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define MyMacro3 MyMacro2(3)"")] - public const int MyMacro3 = unchecked((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 ((int*) -1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static unsafe partial class Methods - {{ - [NativeTypeName(""#define Macro1 reinterpret_cast(-1)"")] - public static readonly int* Macro1 = unchecked((int*)(-1)); - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""const int[2][2]"")] - public static readonly int[][] MyArray = new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }}; - }} -}} -"; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@"namespace ClangSharp.Test -{{ - public static partial class Methods - {{ - [NativeTypeName(""#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"")] - public const int ADDRESS_IN_USE = unchecked((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))); - }} -}} -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedCSharpPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/CXXMethodDeclarationTest.cs deleted file mode 100644 index 2b20f321..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,656 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlCompatibleUnix_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; - - var expectedOutputContents = $@" - - - - - int* - - MyStruct* - - - int* - - null - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = Environment.Is64BitProcess - ? "?MyVoidMethod@MyStruct@@QEAAXXZ" - : "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - MyStruct* - - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@" - - - - - void** - - - int - - MyStruct* - - - int - - - - int - - MyStruct* - - - - int - - MyStruct* - - - int - - - int - - - - int - - int - - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType>((IntPtr)(lpVtbl[0]))(pThis, obj); - }} - - - - int - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType1>((IntPtr)(lpVtbl[1]))(pThis); - }} - - - - int - - int - - - int - - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType2>((IntPtr)(lpVtbl[2]))(pThis, objA, objB); - }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl* - - - int - - MyStruct* - - - int - - - - int - - MyStruct* - - - - int - - MyStruct* - - - int - - - int - - - - int - - int - - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, obj); - }} - - - - int - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); - }} - - - - int - - int - - - int - - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, objA, objB); - }} - - - - - IntPtr - - - IntPtr - - - IntPtr - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl* - - - int - - MyStruct* - - - int - - - - int - - MyStruct* - - - - int - - MyStruct* - - - int - - - int - - - - int - - int - - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, obj); - }} - - - - int - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); - }} - - - - int - - int - - - int - - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, objA, objB); - }} - - - - - int - - int - - - - int - - - int - - int - - - int - - - - - - IntPtr - - - IntPtr - - - IntPtr - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@" - - - - - void - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - MyStruct* - - - - sbyte - - MyStruct* - - - - int - - MyStruct* - - - - void* - - MyStruct* - - - - void - - fixed (MyStruct* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyVoidMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - - - - sbyte - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt8Method>((IntPtr)(lpVtbl[1]))(pThis); - }} - - - - int - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt32Method>((IntPtr)(lpVtbl[2]))(pThis); - }} - - - - void* - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyVoidStarMethod>((IntPtr)(lpVtbl[3]))(pThis); - }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - MyStruct* - - - - sbyte - - MyStruct* - - - - int - - MyStruct* - - - - void* - - MyStruct* - - - - void - - fixed (MyStruct* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyVoidMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - - - - sbyte - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt8Method>((IntPtr)(lpVtbl[1]))(pThis); - }} - - - - int - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt32Method>((IntPtr)(lpVtbl[2]))(pThis); - }} - - - - void* - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyVoidStarMethod>((IntPtr)(lpVtbl[3]))(pThis); - }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/DeprecatedToObsoleteTest.cs deleted file mode 100644 index 2e8b4848..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,551 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlCompatibleUnix_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - Obsolete - int - - int - - - - Obsolete(""This is obsolete."") - int - - int - - - - int - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@" - - - - - int - - 0 - - - - Obsolete - int - - 0 - - - - Obsolete(""This is obsolete."") - int - - 0 - - - - int - - 0 - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - Obsolete - void - - - - Obsolete(""This is obsolete."") - void - - - - void - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@" - - - - - int - return 0; - - - Obsolete - int - return 0; - - - Obsolete(""This is obsolete."") - int - return 0; - - - int - return 0; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @" - - - - void - - - Obsolete - void - - - Obsolete(""This is obsolete."") - void - - - void - - - - IntPtr - - - - - Obsolete - IntPtr - - - - - Obsolete(""This is obsolete."") - IntPtr - - - - - IntPtr - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @" - - - - - void - - - Obsolete - void - - - Obsolete(""This is obsolete."") - void - - - void - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/DigitsSeparatorTest.cs deleted file mode 100644 index 81b04cc5..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/DigitsSeparatorTest.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.XmlCompatibleUnix; - -[Platform("unix")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {type} - - {expectedValue} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs deleted file mode 100644 index dab1c96c..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/EnumDeclarationTest.cs +++ /dev/null @@ -1,730 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlCompatibleUnix_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum : int -{ - MyEnum_Value1, - MyEnum_Value2, - MyEnum_Value3, -} MyEnum; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @" - - - - Flags - int - - int - - 1 - - - - - int - - int - - 1 - - - - - -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - (int)(MyEnum)(10) - - - - int - - (int)(MyEnum)(MyEnum_Value0) - - - - int - - ((int)(MyEnum)(10)) + MyEnum_Value1 - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 10 - - - - - int - - int - - MyEnum1_Value0 - - - - int - - MyEnum1_Value0 + (int)(MyEnum1)(10) - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - int - - 0x80000000 - - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - - - -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - 0x80000000 - - - - - -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - MyEnum1_Value1 - - - - - - uint - - 1 - - - - - -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @" - - - - - uint - - 1 - - - - int - - (int)(MyEnum1_Value1) + 1 - - - - - -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index 3fd49d4e..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,2013 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlCompatibleUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - - int - - return pData[index]; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - bool - - - bool - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - while (true) - {{ - break; - }} - - return 0; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = $@" - - - - - void - - - - void - MyCalledFunction(); - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = $@" - - - - - void - - int - - - int - - - - - void - MyCalledFunction(0, 1); - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 1: - case 2: - {{ - return 3; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 2: - case 3: - {{ - return 5; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = $@" - - - - int - - int - - - int - - - int - - - - - int - - MyEnum - - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = $@" - - - - - int - - bool - - - int - - - int - - return condition ? lhs : rhs; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - while (true) - { - continue; - } - - return 0; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - void* - - void* - - return input; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - MyStructA* - - - - void - - fixed (MyStructA* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - - - - - - void** - - - void - - MyStructB* - - - - void - - fixed (MyStructB* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - - - - - - MyStructB* - - MyStructA* - - return (MyStructB*)(input); - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @" - - - - - int - int x = 0; - int y = 1, z = 2; - - return x + y + z; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - - return rhs; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - - bool - - - int - - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @" - - - - - void - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @" - - - - - float - - - float - - - float - - - float - - - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - int - - MyStruct - - return instance.value; - - - int - - MyStruct* - - return instance->value; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - bool - - MyStruct* - - - MyStruct* - - return lhs->value == rhs->value; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @" - - - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - return {value}; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - double - return {value}; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - float - return {value}; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @" - - - - - void - return; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - return -1; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->a; - } - - - - - int - - - - - - void - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - - - MyStruct - MyStruct myStruct = new MyStruct(); - - return myStruct; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @" - - - - - int* - - int - - return &value; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - return *value; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @" - - - - - bool - - bool - - return !value; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return value{opcode}; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return {opcode}value; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index 4df425ee..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlCompatibleUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @" - - - - - void - - float* - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @" - - - - - void - - IntPtr - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@" - - - - - void - - MyTemplate<{expectedManagedType}> - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@" - - - - - MyTemplate<IntPtr> - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @" - - - - - void - - float - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionPointerDeclarationTest.cs deleted file mode 100644 index 8d727175..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlCompatibleUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - void - - - - IntPtr - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - void - - - - IntPtr - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @" - - - - void - - - - IntPtr - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs deleted file mode 100644 index daca2be6..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/StructDeclarationTest.cs +++ /dev/null @@ -1,2117 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlCompatibleUnix_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - return (byte)((_bitfield2 >> 22) & 0x1u); - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - - - - int - - return (int)(_bitfield2 << 8) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - - - - int - - return (int)(_bitfield2 << 7) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - NativeBitfield(""o0_b0_24"", offset: 0, length: 24) - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - NativeBitfield(""o4_b0_16"", offset: 0, length: 16) - NativeBitfield(""o4_b16_3"", offset: 16, length: 3) - NativeBitfield(""o4_b19_3"", offset: 19, length: 3) - NativeBitfield(""o4_b22_1"", offset: 22, length: 1) - NativeBitfield(""o4_b23_1"", offset: 23, length: 1) - NativeBitfield(""o4_b24_1"", offset: 24, length: 1) - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - return (byte)((_bitfield2 >> 22) & 0x1u); - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - - - - int - - return (int)(_bitfield2 << 8) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - - - - int - - return (int)(_bitfield2 << 7) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - NativeBitfield(""o8_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - NativeBitfield(""o0_b1_1"", offset: 1, length: 1) - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - IntPtr - - - - - void - - - - -"; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - - MyStruct - - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - fixed (MyStruct* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - fixed (MyStruct* pThis = &e0_0_0_0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - - MyStruct - - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - fixed (MyStruct* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - - MyStruct - - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - fixed (MyStruct* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Unix doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Struct - - - ref {expectedManagedType} - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->z; - }} - - - - ref _Anonymous_e__Struct._w_e__Struct - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->w; - }} - - - - ref MyUnion - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->u; - }} - - - - ref {expectedManagedType} - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->buffer1[0]; - }} - - - - ref _Anonymous_e__Struct._buffer2_e__FixedBuffer - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->buffer2; - }} - - - - - {expectedManagedType} - - - _w_e__Struct - - - MyUnion - - - {expectedManagedType} - - - MyUnion - - - - {expectedManagedType} - - - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Struct - - - ref int - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->z; - } - - - - ref int - - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) - { - return ref pField->w; - } - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Struct - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; - - var expectedOutputContents = $@" - - - - - uint - - - void* - - - uint - - - - - uint - - - void* - - - uint - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Struct - - - ref double - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->a; - } - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @" - - - - - void - - - - - - void - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - int - - - int - - - - -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"typedef int size_t; - -struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @" - - - - - UIntPtr - - - - UIntPtr - - - UIntPtr - - - ref UIntPtr - - int - - - fixed (UIntPtr* pThis = &e0) - { - return ref pThis[index]; - } - - - - - - -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @" - - - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct;"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - _MyArray_e__Struct - - - ref int - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->First; - } - - - - - int - - - - - int - - - - - _MyArray_e__Struct - - - _MyArray_e__Struct - - - ref _MyArray_e__Struct - - int - - - fixed (_MyArray_e__Struct* pThis = &e0) - { - return ref pThis[index]; - } - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct;"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous2_e__Struct* pField = &Anonymous.Anonymous1.Anonymous2) - { - return ref pField->Value1; - } - - - - ref int - - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous3_e__Struct* pField = &Anonymous.Anonymous1.Anonymous3) - { - return ref pField->Value2; - } - - - - - _Anonymous1_e__Struct - - - - _Anonymous2_e__Struct - - - _Anonymous3_e__Struct - - - - int - - - - - int - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/UnionDeclarationTest.cs deleted file mode 100644 index 31e57bb9..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/UnionDeclarationTest.cs +++ /dev/null @@ -1,1459 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlCompatibleUnix_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; - - var expectedOutputContents = $@" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - return (byte)((_bitfield2 >> 22) & 0x1u); - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - - - - int - - return (int)(_bitfield2 << 8) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - - - - int - - return (int)(_bitfield2 << 7) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - - MyUnion - - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - fixed (MyUnion* pThis = &e0_0_0_0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - - MyUnion - - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - - MyUnion - - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Unix doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Union - - - ref {expectedManagedType} - - fixed (_Anonymous_e__Union* pField = &Anonymous) - {{ - return ref pField->a; - }} - - - - ref MyStruct - - fixed (_Anonymous_e__Union* pField = &Anonymous) - {{ - return ref pField->s; - }} - - - - ref {expectedManagedType} - - fixed (_Anonymous_e__Union* pField = &Anonymous) - {{ - return ref pField->buffer[0]; - }} - - - - - {expectedManagedType} - - - MyStruct - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Union - - - ref int - - fixed (_Anonymous_e__Union* pField = &Anonymous) - { - return ref pField->z; - } - - - - ref int - - fixed (_Anonymous_e__Union._Anonymous1_e__Union* pField = &Anonymous.Anonymous1) - { - return ref pField->w; - } - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Union - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Union - - - ref double - - fixed (_Anonymous_e__Union* pField = &Anonymous) - { - return ref pField->a; - } - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@" - - - - - IntPtr - - - _Anonymous_e__Struct - - - ref IntPtr - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->First; - }} - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct - - fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) - {{ - return ref pField->A; - }} - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct - - fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) - {{ - return ref pField->B; - }} - - - - - IntPtr - - - _Anonymous_e__Union - - - - _A_e__Struct - - - _B_e__Struct - - - - IntPtr - - - - - IntPtr - - - - - - - IntPtr - - - IntPtr - - - ref IntPtr - - int - - - fixed (IntPtr* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs deleted file mode 100644 index 776932f8..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleUnix/VarDeclarationTest.cs +++ /dev/null @@ -1,543 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlCompatibleUnix_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@" - - - - - Guid - - new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46) - - - - - -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - {expectedManagedValue} - - - - {expectedManagedType} - - {expectedManagedValue} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@" - - - - - int - - 0 + 1 - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - uint[] - - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} - - - - uint[] - - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} - - - - uint[] - - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} - - - - byte[] - - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} - - - - ReadOnlySpan<byte> - - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - uint[] - - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} - - - - uint[] - - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} - - - - uint[] - - new uint[] {{ 0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000 }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} - - - - byte[] - - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} - - - - ReadOnlySpan<byte> - - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@" - - - - - IntPtr - - - - (nint)(0x80000000) - - - - - - int - - - - (int)(0x80000000) - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@" - - - - - uint - - - - (uint)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))) - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@" - - - - - int* - - - ((int*)(-1)) - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@" - - - - - int* - - - - (int*)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@" - - - - - int[][] - - new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))) - - - - - - -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlCompatibleUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/CXXMethodDeclarationTest.cs deleted file mode 100644 index 32f5b3a0..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,657 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlCompatibleWindows_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; - - var expectedOutputContents = $@" - - - - - int* - - MyStruct* - - - int* - - null - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = Environment.Is64BitProcess - ? "?MyVoidMethod@MyStruct@@QEAAXXZ" - : "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - MyStruct* - - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@" - - - - - void** - - - int - - MyStruct* - - - int - - - int - - - - int - - MyStruct* - - - - int - - MyStruct* - - - int - - - - int - - int - - - int - - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType>((IntPtr)(lpVtbl[0]))(pThis, objA, objB); - }} - - - - int - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType1>((IntPtr)(lpVtbl[1]))(pThis); - }} - - - - int - - int - - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType2>((IntPtr)(lpVtbl[2]))(pThis, obj); - }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl* - - - int - - MyStruct* - - - int - - - int - - - - int - - MyStruct* - - - - int - - MyStruct* - - - int - - - - int - - int - - - int - - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, objA, objB); - }} - - - - int - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); - }} - - - - int - - int - - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, obj); - }} - - - - - IntPtr - - - IntPtr - - - IntPtr - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl* - - - int - - MyStruct* - - - int - - - int - - - - int - - MyStruct* - - - - int - - MyStruct* - - - int - - - - int - - int - - - int - - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType>(lpVtbl->GetType)(pThis, objA, objB); - }} - - - - int - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType1>(lpVtbl->GetType1)(pThis); - }} - - - - int - - int - - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_GetType2>(lpVtbl->GetType2)(pThis, obj); - }} - - - - - int - - int - - - int - - - - int - - - int - - int - - - - - - IntPtr - - - IntPtr - - - IntPtr - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@" - - - - - void - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - MyStruct* - - - - sbyte - - MyStruct* - - - - int - - MyStruct* - - - - void* - - MyStruct* - - - - void - - fixed (MyStruct* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyVoidMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - - - - sbyte - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt8Method>((IntPtr)(lpVtbl[1]))(pThis); - }} - - - - int - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt32Method>((IntPtr)(lpVtbl[2]))(pThis); - }} - - - - void* - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyVoidStarMethod>((IntPtr)(lpVtbl[3]))(pThis); - }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - MyStruct* - - - - sbyte - - MyStruct* - - - - int - - MyStruct* - - - - void* - - MyStruct* - - - - void - - fixed (MyStruct* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyVoidMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - - - - sbyte - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt8Method>((IntPtr)(lpVtbl[1]))(pThis); - }} - - - - int - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyInt32Method>((IntPtr)(lpVtbl[2]))(pThis); - }} - - - - void* - - fixed (MyStruct* pThis = &this) - {{ - return Marshal.GetDelegateForFunctionPointer<_MyVoidStarMethod>((IntPtr)(lpVtbl[3]))(pThis); - }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/DeprecatedToObsoleteTest.cs deleted file mode 100644 index 5e571f29..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,551 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlCompatibleWindows_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - Obsolete - int - - int - - - - Obsolete(""This is obsolete."") - int - - int - - - - int - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@" - - - - - int - - 0 - - - - Obsolete - int - - 0 - - - - Obsolete(""This is obsolete."") - int - - 0 - - - - int - - 0 - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - Obsolete - void - - - - Obsolete(""This is obsolete."") - void - - - - void - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@" - - - - - int - return 0; - - - Obsolete - int - return 0; - - - Obsolete(""This is obsolete."") - int - return 0; - - - int - return 0; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @" - - - - void - - - Obsolete - void - - - Obsolete(""This is obsolete."") - void - - - void - - - - IntPtr - - - - - Obsolete - IntPtr - - - - - Obsolete(""This is obsolete."") - IntPtr - - - - - IntPtr - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @" - - - - - void - - - Obsolete - void - - - Obsolete(""This is obsolete."") - void - - - void - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/DigitsSeparatorTest.cs deleted file mode 100644 index ba97af4f..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/DigitsSeparatorTest.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.XmlCompatibleWindows; - -[Platform("win")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {type} - - {expectedValue} - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs deleted file mode 100644 index c196d58e..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/EnumDeclarationTest.cs +++ /dev/null @@ -1,730 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlCompatibleWindows_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum : int -{ - MyEnum_Value1, - MyEnum_Value2, - MyEnum_Value3, -} MyEnum; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @" - - - - Flags - int - - int - - 1 - - - - - int - - int - - 1 - - - - - -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - (int)(MyEnum)(10) - - - - int - - (int)(MyEnum)(MyEnum_Value0) - - - - int - - ((int)(MyEnum)(10)) + MyEnum_Value1 - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 10 - - - - - int - - int - - MyEnum1_Value0 - - - - int - - MyEnum1_Value0 + (int)(MyEnum1)(10) - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - int - - 0x80000000 - - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - - - -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - 0x80000000 - - - - - -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - MyEnum1_Value1 - - - - - - int - - 1 - - - - - -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @" - - - - - int - - 1 - - - - int - - (int)(MyEnum1_Value1) + 1 - - - - - -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index ad035246..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,2013 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlCompatibleWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - - int - - return pData[index]; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - bool - - - bool - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - while (true) - {{ - break; - }} - - return 0; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = $@" - - - - - void - - - - void - MyCalledFunction(); - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = $@" - - - - - void - - int - - - int - - - - - void - MyCalledFunction(0, 1); - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 1: - case 2: - {{ - return 3; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 2: - case 3: - {{ - return 5; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = $@" - - - - int - - int - - - int - - - int - - - - - int - - MyEnum - - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = $@" - - - - - int - - bool - - - int - - - int - - return condition ? lhs : rhs; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - while (true) - { - continue; - } - - return 0; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - void* - - void* - - return input; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - MyStructA* - - - - void - - fixed (MyStructA* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - - - - - - void** - - - void - - MyStructB* - - - - void - - fixed (MyStructB* pThis = &this) - {{ - Marshal.GetDelegateForFunctionPointer<_MyMethod>((IntPtr)(lpVtbl[0]))(pThis); - }} - - - - - - MyStructB* - - MyStructA* - - return (MyStructB*)(input); - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @" - - - - - int - int x = 0; - int y = 1, z = 2; - - return x + y + z; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - - return rhs; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - - bool - - - int - - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @" - - - - - void - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @" - - - - - float - - - float - - - float - - - float - - - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - int - - MyStruct - - return instance.value; - - - int - - MyStruct* - - return instance->value; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - bool - - MyStruct* - - - MyStruct* - - return lhs->value == rhs->value; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @" - - - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - return {value}; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - double - return {value}; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - float - return {value}; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @" - - - - - void - return; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - return -1; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->a; - } - - - - - int - - - - - - void - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - - - MyStruct - MyStruct myStruct = new MyStruct(); - - return myStruct; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @" - - - - - int* - - int - - return &value; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - return *value; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @" - - - - - bool - - bool - - return !value; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return value{opcode}; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return {opcode}value; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index a6f62ac8..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlCompatibleWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @" - - - - - void - - float* - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @" - - - - - void - - IntPtr - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@" - - - - - void - - MyTemplate<{expectedManagedType}> - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@" - - - - - MyTemplate<IntPtr> - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @" - - - - - void - - float - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionPointerDeclarationTest.cs deleted file mode 100644 index d218388b..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlCompatibleWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - void - - - - IntPtr - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - void - - - - IntPtr - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @" - - - - void - - - - IntPtr - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs deleted file mode 100644 index c443c420..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/StructDeclarationTest.cs +++ /dev/null @@ -1,2126 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlCompatibleWindows_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - - byte - - return (byte)(_bitfield3 & 0x1u); - - - - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - - - - int - - - int - - return (_bitfield4 << 31) >> 31; - - - - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - - - - int - - return (_bitfield4 << 30) >> 31; - - - - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - NativeBitfield(""o0_b0_24"", offset: 0, length: 24) - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - NativeBitfield(""o4_b0_16"", offset: 0, length: 16) - NativeBitfield(""o4_b16_3"", offset: 16, length: 3) - NativeBitfield(""o4_b19_3"", offset: 19, length: 3) - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - NativeBitfield(""o8_b0_1"", offset: 0, length: 1) - byte - - - byte - - return (byte)(_bitfield3 & 0x1u); - - - - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - - - - NativeBitfield(""o12_b0_1"", offset: 0, length: 1) - NativeBitfield(""o12_b1_1"", offset: 1, length: 1) - int - - - int - - return (_bitfield4 << 31) >> 31; - - - - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - - - - int - - return (_bitfield4 << 30) >> 31; - - - - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - NativeBitfield(""o8_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - NativeBitfield(""o0_b1_1"", offset: 1, length: 1) - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - IntPtr - - - - - void - - - - -"; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - - MyStruct - - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - fixed (MyStruct* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - fixed (MyStruct* pThis = &e0_0_0_0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - - MyStruct - - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - fixed (MyStruct* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - - MyStruct - - - MyStruct - - - MyStruct - - - ref MyStruct - - int - - - fixed (MyStruct* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Struct - - - ref {expectedManagedType} - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->z; - }} - - - - ref _Anonymous_e__Struct._w_e__Struct - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->w; - }} - - - - ref MyUnion - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->u; - }} - - - - ref {expectedManagedType} - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->buffer1[0]; - }} - - - - ref _Anonymous_e__Struct._buffer2_e__FixedBuffer - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->buffer2; - }} - - - - - {expectedManagedType} - - - _w_e__Struct - - - MyUnion - - - {expectedManagedType} - - - MyUnion - - - - {expectedManagedType} - - - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Struct - - - ref int - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->z; - } - - - - ref int - - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct* pField = &Anonymous.Anonymous1) - { - return ref pField->w; - } - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Struct - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; - - var expectedOutputContents = $@" - - - - - uint - - - void* - - - uint - - - - - uint - - - void* - - - uint - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Struct - - - ref double - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->a; - } - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @" - - - - - void - - - - - - void - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - int - - - int - - - - -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @" - - - - - UIntPtr - - - - UIntPtr - - - UIntPtr - - - ref UIntPtr - - int - - - fixed (UIntPtr* pThis = &e0) - { - return ref pThis[index]; - } - - - - - - -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @" - - - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct;"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - _MyArray_e__Struct - - - ref int - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - { - return ref pField->First; - } - - - - - int - - - - - int - - - - - _MyArray_e__Struct - - - _MyArray_e__Struct - - - ref _MyArray_e__Struct - - int - - - fixed (_MyArray_e__Struct* pThis = &e0) - { - return ref pThis[index]; - } - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct;"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous2_e__Struct* pField = &Anonymous.Anonymous1.Anonymous2) - { - return ref pField->Value1; - } - - - - ref int - - fixed (_Anonymous_e__Struct._Anonymous1_e__Struct._Anonymous3_e__Struct* pField = &Anonymous.Anonymous1.Anonymous3) - { - return ref pField->Value2; - } - - - - - _Anonymous1_e__Struct - - - - _Anonymous2_e__Struct - - - _Anonymous3_e__Struct - - - - int - - - - - int - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/UnionDeclarationTest.cs deleted file mode 100644 index 13f0d054..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/UnionDeclarationTest.cs +++ /dev/null @@ -1,1445 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlCompatibleWindows_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; - - var expectedOutputContents = $@" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - - byte - - return (byte)(_bitfield3 & 0x1u); - - - - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - - - - int - - - int - - return (_bitfield4 << 31) >> 31; - - - - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - - - - int - - return (_bitfield4 << 30) >> 31; - - - - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - - MyUnion - - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - fixed (MyUnion* pThis = &e0_0_0_0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - - MyUnion - - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - - MyUnion - - - MyUnion - - - MyUnion - - - ref MyUnion - - int - - - fixed (MyUnion* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Union - - - ref {expectedManagedType} - - fixed (_Anonymous_e__Union* pField = &Anonymous) - {{ - return ref pField->a; - }} - - - - ref MyStruct - - fixed (_Anonymous_e__Union* pField = &Anonymous) - {{ - return ref pField->s; - }} - - - - ref {expectedManagedType} - - fixed (_Anonymous_e__Union* pField = &Anonymous) - {{ - return ref pField->buffer[0]; - }} - - - - - {expectedManagedType} - - - MyStruct - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Union - - - ref int - - fixed (_Anonymous_e__Union* pField = &Anonymous) - { - return ref pField->z; - } - - - - ref int - - fixed (_Anonymous_e__Union._Anonymous1_e__Union* pField = &Anonymous.Anonymous1) - { - return ref pField->w; - } - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Union - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Union - - - ref double - - fixed (_Anonymous_e__Union* pField = &Anonymous) - { - return ref pField->a; - } - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@" - - - - - int - - - _Anonymous_e__Struct - - - ref int - - fixed (_Anonymous_e__Struct* pField = &Anonymous) - {{ - return ref pField->First; - }} - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct - - fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) - {{ - return ref pField->A; - }} - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct - - fixed (_Anonymous_e__Struct._Anonymous_e__Union* pField = &Anonymous.Anonymous) - {{ - return ref pField->B; - }} - - - - - int - - - _Anonymous_e__Union - - - - _A_e__Struct - - - _B_e__Struct - - - - int - - - - - int - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs deleted file mode 100644 index fcdace42..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlCompatibleWindows/VarDeclarationTest.cs +++ /dev/null @@ -1,543 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlCompatibleWindows_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@" - - - - - Guid - - new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46) - - - - - -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - {expectedManagedValue} - - - - {expectedManagedType} - - {expectedManagedValue} - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@" - - - - - int - - 0 + 1 - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} - - - - byte[] - - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} - - - - ReadOnlySpan<byte> - - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} - - - - byte[] - - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} - - - - ReadOnlySpan<byte> - - new byte[] {{ 0x54, 0x65, 0x73, 0x74, 0x00, 0x5C, 0x0D, 0x0A, 0x09, 0x22, 0x00 }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@" - - - - - int - - - - (int)(0x80000000) - - - - - - int - - - - (int)(0x80000000) - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@" - - - - - uint - - - - (uint)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))) - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@" - - - - - int* - - - ((int*)(-1)) - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@" - - - - - int* - - - - (int*)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@" - - - - - int[][] - - new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }} - - - - - -"; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))) - - - - - - -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/CXXMethodDeclarationTest.cs deleted file mode 100644 index f05bd5fc..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,477 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlDefaultUnix_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; - - var expectedOutputContents = $@" - - - - - int* - - MyStruct* - - - int* - - null - - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = Environment.Is64BitProcess - ? "?MyVoidMethod@MyStruct@@QEAAXXZ" - : "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - MyStruct* - - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@" - - - - - void** - - - int - - int - - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - int - - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl* - - - int - - int - - - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - int - - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - int - - - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - - delegate* unmanaged[Thiscall]<MyStruct*, int, int> - - - delegate* unmanaged[Thiscall]<MyStruct*, int> - - - delegate* unmanaged[Thiscall]<MyStruct*, int, int, int> - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl<MyStruct>* - - - int - - int - - - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - int - - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - int - - - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - - int - - int - - - - int - - - int - - int - - - int - - - - - - delegate* unmanaged[Thiscall]<TSelf*, int, int> - - - delegate* unmanaged[Thiscall]<TSelf*, int> - - - delegate* unmanaged[Thiscall]<TSelf*, int, int, int> - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@" - - - - - void - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - sbyte - - return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - void* - - return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - sbyte - - return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - void* - - return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/DeprecatedToObsoleteTest.cs deleted file mode 100644 index 7cd8fca6..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,537 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlDefaultUnix_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - Obsolete - int - - int - - - - Obsolete(""This is obsolete."") - int - - int - - - - int - - int - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@" - - - - - int - - 0 - - - - Obsolete - int - - 0 - - - - Obsolete(""This is obsolete."") - int - - 0 - - - - int - - 0 - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - Obsolete - void - - - - Obsolete(""This is obsolete."") - void - - - - void - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@" - - - - - int - return 0; - - - Obsolete - int - return 0; - - - Obsolete(""This is obsolete."") - int - return 0; - - - int - return 0; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - - Obsolete - delegate* unmanaged[Cdecl]<void> - - - - - Obsolete(""This is obsolete."") - delegate* unmanaged[Cdecl]<void> - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @" - - - - - void - - - Obsolete - void - - - Obsolete(""This is obsolete."") - void - - - void - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/DigitsSeparatorTest.cs deleted file mode 100644 index 156044c1..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/DigitsSeparatorTest.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.XmlDefaultUnix; - -[Platform("unix")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {type} - - {expectedValue} - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/EnumDeclarationTest.cs deleted file mode 100644 index ae891ca8..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/EnumDeclarationTest.cs +++ /dev/null @@ -1,730 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlDefaultUnix_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum : int -{ - MyEnum_Value1, - MyEnum_Value2, - MyEnum_Value3, -} MyEnum; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @" - - - - Flags - int - - int - - 1 - - - - - int - - int - - 1 - - - - - -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - (int)(MyEnum)(10) - - - - int - - (int)(MyEnum)(MyEnum_Value0) - - - - int - - ((int)(MyEnum)(10)) + MyEnum_Value1 - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 10 - - - - - int - - int - - MyEnum1_Value0 - - - - int - - MyEnum1_Value0 + (int)(MyEnum1)(10) - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - int - - 0x80000000 - - - - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - - - -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - 0x80000000 - - - - - -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - MyEnum1_Value1 - - - - - - uint - - 1 - - - - - -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @" - - - - - uint - - 1 - - - - int - - (int)(MyEnum1_Value1) + 1 - - - - - -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index d4d7654f..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,1992 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlDefaultUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - - int - - return pData[index]; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - bool - - - bool - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - while (true) - {{ - break; - }} - - return 0; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = $@" - - - - - void - - - - void - MyCalledFunction(); - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = $@" - - - - - void - - int - - - int - - - - - void - MyCalledFunction(0, 1); - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 1: - case 2: - {{ - return 3; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 2: - case 3: - {{ - return 5; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = $@" - - - - int - - int - - - int - - - int - - - - - int - - MyEnum - - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = $@" - - - - - int - - bool - - - int - - - int - - return condition ? lhs : rhs; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - while (true) - { - continue; - } - - return 0; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - void* - - void* - - return input; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStructA*, void>)(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); - - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStructB*, void>)(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); - - - - - - MyStructB* - - MyStructA* - - return (MyStructB*)(input); - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @" - - - - - int - int x = 0; - int y = 1, z = 2; - - return x + y + z; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - - return rhs; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - - bool - - - int - - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @" - - - - - void - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @" - - - - - float - - - float - - - float - - - float - - - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - int - - MyStruct - - return instance.value; - - - int - - MyStruct* - - return instance->value; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - bool - - MyStruct* - - - MyStruct* - - return lhs->value == rhs->value; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @" - - - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - return {value}; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - double - return {value}; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - float - return {value}; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @" - - - - - void - return; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - return -1; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.a; - - - - - int - - - - - - void - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - - - MyStruct - MyStruct myStruct = new MyStruct(); - - return myStruct; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @" - - - - - int* - - int - - return &value; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - return *value; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @" - - - - - bool - - bool - - return !value; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return value{opcode}; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return {opcode}value; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index 8ef79a6b..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlDefaultUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @" - - - - - void - - float* - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @" - - - - - void - - delegate* unmanaged[Cdecl]<void> - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@" - - - - - void - - MyTemplate<{expectedManagedType}> - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@" - - - - - MyTemplate<IntPtr> - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @" - - - - - void - - float - - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionPointerDeclarationTest.cs deleted file mode 100644 index 7ddd213a..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlDefaultUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Stdcall]<void> - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlDefaultUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/StructDeclarationTest.cs deleted file mode 100644 index a137a9f1..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/StructDeclarationTest.cs +++ /dev/null @@ -1,1951 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlDefaultUnix_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - return ref Unsafe.Add(ref e0, index); - - - - Span<{expectedManagedType}> - - int - - MemoryMarshal.CreateSpan(ref e0, length); - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - return (byte)((_bitfield2 >> 22) & 0x1u); - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - - - - int - - return (int)(_bitfield2 << 8) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - - - - int - - return (int)(_bitfield2 << 7) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - NativeBitfield(""o0_b0_24"", offset: 0, length: 24) - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - NativeBitfield(""o4_b0_16"", offset: 0, length: 16) - NativeBitfield(""o4_b16_3"", offset: 16, length: 3) - NativeBitfield(""o4_b19_3"", offset: 19, length: 3) - NativeBitfield(""o4_b22_1"", offset: 22, length: 1) - NativeBitfield(""o4_b23_1"", offset: 23, length: 1) - NativeBitfield(""o4_b24_1"", offset: 24, length: 1) - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - return (byte)((_bitfield2 >> 22) & 0x1u); - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - - - - int - - return (int)(_bitfield2 << 8) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - - - - int - - return (int)(_bitfield2 << 7) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - NativeBitfield(""o8_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - NativeBitfield(""o0_b1_1"", offset: 1, length: 1) - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - - void - - - - -"; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(2 * 1 * 3 * 4) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(2 * 1 * 3 * 4) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Unix doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Struct - - - ref {expectedManagedType} - - return ref Anonymous.z; - - - - ref _Anonymous_e__Struct._w_e__Struct - - return ref Anonymous.w; - - - - ref MyUnion - - return ref Anonymous.u; - - - - Span<{expectedManagedType}> - - return Anonymous.buffer1; - - - - Span<MyUnion> - - return Anonymous.buffer2; - - - - - {expectedManagedType} - - - _w_e__Struct - - - MyUnion - - - {expectedManagedType} - - - MyUnion - - - - {expectedManagedType} - - - - InlineArray(4) - - {expectedManagedType} - - - - InlineArray(4) - - MyUnion - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.z; - - - - ref int - - return ref Anonymous.Anonymous1.w; - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Struct - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; - - var expectedOutputContents = $@" - - - - - uint - - - void* - - - uint - - - - - uint - - - void* - - - uint - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Struct - - - ref double - - return ref Anonymous.a; - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @" - - - - - void - - - - - - void - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - int - - - int - - - - -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"typedef int size_t; - -struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @" - - - - - nuint - - - InlineArray(2) - - nuint - - - - - -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @" - - - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - _MyArray_e__Struct - - - ref int - - return ref Anonymous.First; - - - - - int - - - - - int - - - - InlineArray(2) - - _MyArray_e__Struct - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.Anonymous1.Anonymous2.Value1; - - - - ref int - - return ref Anonymous.Anonymous1.Anonymous3.Value2; - - - - - _Anonymous1_e__Struct - - - - _Anonymous2_e__Struct - - - _Anonymous3_e__Struct - - - - int - - - - - int - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/UnionDeclarationTest.cs deleted file mode 100644 index 51afb019..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/UnionDeclarationTest.cs +++ /dev/null @@ -1,1311 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlDefaultUnix_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; - - var expectedOutputContents = $@" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - return (byte)((_bitfield2 >> 22) & 0x1u); - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - - - - int - - return (int)(_bitfield2 << 8) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - - - - int - - return (int)(_bitfield2 << 7) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(2 * 1 * 3 * 4) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(2 * 1 * 3 * 4) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Unix doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Union - - - ref {expectedManagedType} - - return ref Anonymous.a; - - - - ref MyStruct - - return ref Anonymous.s; - - - - Span<{expectedManagedType}> - - return Anonymous.buffer; - - - - - {expectedManagedType} - - - MyStruct - - - {expectedManagedType} - - - InlineArray(4) - - {expectedManagedType} - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Union - - - ref int - - return ref Anonymous.z; - - - - ref int - - return ref Anonymous.Anonymous1.w; - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Union - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Union - - - ref double - - return ref Anonymous.a; - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@" - - - - - nint - - - _Anonymous_e__Struct - - - ref nint - - return ref Anonymous.First; - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct - - return ref Anonymous.Anonymous.A; - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct - - return ref Anonymous.Anonymous.B; - - - - - nint - - - _Anonymous_e__Union - - - - _A_e__Struct - - - _B_e__Struct - - - - nint - - - - - nint - - - - - - InlineArray(2) - - nint - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/VarDeclarationTest.cs deleted file mode 100644 index 689bfe63..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultUnix/VarDeclarationTest.cs +++ /dev/null @@ -1,543 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlDefaultUnix_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@" - - - - - Guid - - new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46) - - - - - -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - {expectedManagedValue} - - - - {expectedManagedType} - - {expectedManagedValue} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@" - - - - - int - - 0 + 1 - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<uint> - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - uint[] - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - ReadOnlySpan<uint> - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - byte[] - - ""Test\0\\\r\n\t\""""u8.ToArray() - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<uint> - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - uint[] - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - ReadOnlySpan<uint> - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - byte[] - - ""Test\0\\\r\n\t\""""u8.ToArray() - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@" - - - - - nint - - - - (nint)(0x80000000) - - - - - - int - - - - (int)(0x80000000) - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@" - - - - - uint - - - - (uint)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))) - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@" - - - - - int* - - - ((int*)(-1)) - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@" - - - - - int* - - - - (int*)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@" - - - - - int[][] - - new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))) - - - - - - -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/CXXMethodDeclarationTest.cs deleted file mode 100644 index dc80a866..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,477 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlDefaultWindows_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; - - var expectedOutputContents = $@" - - - - - int* - - MyStruct* - - - int* - - null - - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = Environment.Is64BitProcess - ? "?MyVoidMethod@MyStruct@@QEAAXXZ" - : "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - MyStruct* - - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@" - - - - - void** - - - int - - int - - - int - - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int, int>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl* - - - int - - int - - - int - - - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - int - - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - - delegate* unmanaged[Thiscall]<MyStruct*, int, int, int> - - - delegate* unmanaged[Thiscall]<MyStruct*, int> - - - delegate* unmanaged[Thiscall]<MyStruct*, int, int> - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl<MyStruct>* - - - int - - int - - - int - - - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - int - - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - - int - - int - - - int - - - - int - - - int - - int - - - - - - delegate* unmanaged[Thiscall]<TSelf*, int, int, int> - - - delegate* unmanaged[Thiscall]<TSelf*, int> - - - delegate* unmanaged[Thiscall]<TSelf*, int, int> - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@" - - - - - void - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - sbyte - - return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - void* - - return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - sbyte - - return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - void* - - return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/DeprecatedToObsoleteTest.cs deleted file mode 100644 index 0a45b2d1..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,537 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlDefaultWindows_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - Obsolete - int - - int - - - - Obsolete(""This is obsolete."") - int - - int - - - - int - - int - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@" - - - - - int - - 0 - - - - Obsolete - int - - 0 - - - - Obsolete(""This is obsolete."") - int - - 0 - - - - int - - 0 - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - Obsolete - void - - - - Obsolete(""This is obsolete."") - void - - - - void - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@" - - - - - int - return 0; - - - Obsolete - int - return 0; - - - Obsolete(""This is obsolete."") - int - return 0; - - - int - return 0; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - - Obsolete - delegate* unmanaged[Cdecl]<void> - - - - - Obsolete(""This is obsolete."") - delegate* unmanaged[Cdecl]<void> - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @" - - - - - void - - - Obsolete - void - - - Obsolete(""This is obsolete."") - void - - - void - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/DigitsSeparatorTest.cs deleted file mode 100644 index 6cecde9a..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/DigitsSeparatorTest.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.XmlDefaultWindows; - -[Platform("win")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {type} - - {expectedValue} - - - - - -"; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/EnumDeclarationTest.cs deleted file mode 100644 index 685f8e36..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/EnumDeclarationTest.cs +++ /dev/null @@ -1,730 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlDefaultWindows_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum : int -{ - MyEnum_Value1, - MyEnum_Value2, - MyEnum_Value3, -} MyEnum; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @" - - - - Flags - int - - int - - 1 - - - - - int - - int - - 1 - - - - - -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - (int)(MyEnum)(10) - - - - int - - (int)(MyEnum)(MyEnum_Value0) - - - - int - - ((int)(MyEnum)(10)) + MyEnum_Value1 - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 10 - - - - - int - - int - - MyEnum1_Value0 - - - - int - - MyEnum1_Value0 + (int)(MyEnum1)(10) - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - int - - 0x80000000 - - - - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - - - -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - 0x80000000 - - - - - -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - MyEnum1_Value1 - - - - - - int - - 1 - - - - - -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @" - - - - - int - - 1 - - - - int - - (int)(MyEnum1_Value1) + 1 - - - - - -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index 406a488f..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,1992 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlDefaultWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - - int - - return pData[index]; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - bool - - - bool - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - while (true) - {{ - break; - }} - - return 0; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = $@" - - - - - void - - - - void - MyCalledFunction(); - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = $@" - - - - - void - - int - - - int - - - - - void - MyCalledFunction(0, 1); - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 1: - case 2: - {{ - return 3; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 2: - case 3: - {{ - return 5; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = $@" - - - - int - - int - - - int - - - int - - - - - int - - MyEnum - - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = $@" - - - - - int - - bool - - - int - - - int - - return condition ? lhs : rhs; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - while (true) - { - continue; - } - - return 0; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - void* - - void* - - return input; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStructA*, void>)(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); - - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStructB*, void>)(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); - - - - - - MyStructB* - - MyStructA* - - return (MyStructB*)(input); - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @" - - - - - int - int x = 0; - int y = 1, z = 2; - - return x + y + z; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - - return rhs; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - - bool - - - int - - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @" - - - - - void - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @" - - - - - float - - - float - - - float - - - float - - - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - int - - MyStruct - - return instance.value; - - - int - - MyStruct* - - return instance->value; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - bool - - MyStruct* - - - MyStruct* - - return lhs->value == rhs->value; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @" - - - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - return {value}; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - double - return {value}; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - float - return {value}; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @" - - - - - void - return; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - return -1; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.a; - - - - - int - - - - - - void - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - - - MyStruct - MyStruct myStruct = new MyStruct(); - - return myStruct; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @" - - - - - int* - - int - - return &value; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - return *value; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @" - - - - - bool - - bool - - return !value; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return value{opcode}; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return {opcode}value; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index 39c1c6fa..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlDefaultWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @" - - - - - void - - float* - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @" - - - - - void - - delegate* unmanaged[Cdecl]<void> - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@" - - - - - void - - MyTemplate<{expectedManagedType}> - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@" - - - - - MyTemplate<IntPtr> - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @" - - - - - void - - float - - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionPointerDeclarationTest.cs deleted file mode 100644 index 373f3da5..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlDefaultWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Stdcall]<void> - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlDefaultWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/StructDeclarationTest.cs deleted file mode 100644 index 324ffced..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/StructDeclarationTest.cs +++ /dev/null @@ -1,1961 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlDefaultWindows_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - return ref Unsafe.Add(ref e0, index); - - - - Span<{expectedManagedType}> - - int - - MemoryMarshal.CreateSpan(ref e0, length); - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - - byte - - return (byte)(_bitfield3 & 0x1u); - - - - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - - - - int - - - int - - return (_bitfield4 << 31) >> 31; - - - - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - - - - int - - return (_bitfield4 << 30) >> 31; - - - - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - NativeBitfield(""o0_b0_24"", offset: 0, length: 24) - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - NativeBitfield(""o4_b0_16"", offset: 0, length: 16) - NativeBitfield(""o4_b16_3"", offset: 16, length: 3) - NativeBitfield(""o4_b19_3"", offset: 19, length: 3) - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - NativeBitfield(""o8_b0_1"", offset: 0, length: 1) - byte - - - byte - - return (byte)(_bitfield3 & 0x1u); - - - - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - - - - NativeBitfield(""o12_b0_1"", offset: 0, length: 1) - NativeBitfield(""o12_b1_1"", offset: 1, length: 1) - int - - - int - - return (_bitfield4 << 31) >> 31; - - - - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - - - - int - - return (_bitfield4 << 30) >> 31; - - - - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - NativeBitfield(""o8_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - NativeBitfield(""o0_b1_1"", offset: 1, length: 1) - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - - void - - - - -"; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(2 * 1 * 3 * 4) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(2 * 1 * 3 * 4) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Struct - - - ref {expectedManagedType} - - return ref Anonymous.z; - - - - ref _Anonymous_e__Struct._w_e__Struct - - return ref Anonymous.w; - - - - ref MyUnion - - return ref Anonymous.u; - - - - Span<{expectedManagedType}> - - return Anonymous.buffer1; - - - - Span<MyUnion> - - return Anonymous.buffer2; - - - - - {expectedManagedType} - - - _w_e__Struct - - - MyUnion - - - {expectedManagedType} - - - MyUnion - - - - {expectedManagedType} - - - - InlineArray(4) - - {expectedManagedType} - - - - InlineArray(4) - - MyUnion - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.z; - - - - ref int - - return ref Anonymous.Anonymous1.w; - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Struct - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; - - var expectedOutputContents = $@" - - - - - uint - - - void* - - - uint - - - - - uint - - - void* - - - uint - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Struct - - - ref double - - return ref Anonymous.a; - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @" - - - - - void - - - - - - void - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - int - - - int - - - - -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @" - - - - - nuint - - - InlineArray(2) - - nuint - - - - - -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @" - - - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - _MyArray_e__Struct - - - ref int - - return ref Anonymous.First; - - - - - int - - - - - int - - - - InlineArray(2) - - _MyArray_e__Struct - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.Anonymous1.Anonymous2.Value1; - - - - ref int - - return ref Anonymous.Anonymous1.Anonymous3.Value2; - - - - - _Anonymous1_e__Struct - - - - _Anonymous2_e__Struct - - - _Anonymous3_e__Struct - - - - int - - - - - int - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/UnionDeclarationTest.cs deleted file mode 100644 index ee8d74a8..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/UnionDeclarationTest.cs +++ /dev/null @@ -1,1317 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlDefaultWindows_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; - - var expectedOutputContents = $@" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - - byte - - return (byte)(_bitfield3 & 0x1u); - - - - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - - - - int - - - int - - return (_bitfield4 << 31) >> 31; - - - - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - - - - int - - return (_bitfield4 << 30) >> 31; - - - - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(2 * 1 * 3 * 4) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(2 * 1 * 3 * 4) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Union - - - ref {expectedManagedType} - - return ref Anonymous.a; - - - - ref MyStruct - - return ref Anonymous.s; - - - - Span<{expectedManagedType}> - - return Anonymous.buffer; - - - - - {expectedManagedType} - - - MyStruct - - - {expectedManagedType} - - - InlineArray(4) - - {expectedManagedType} - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Union - - - ref int - - return ref Anonymous.z; - - - - ref int - - return ref Anonymous.Anonymous1.w; - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Union - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Union - - - ref double - - return ref Anonymous.a; - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@" - - - - - int - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.First; - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct - - return ref Anonymous.Anonymous.A; - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct - - return ref Anonymous.Anonymous.B; - - - - - int - - - _Anonymous_e__Union - - - - _A_e__Struct - - - _B_e__Struct - - - - int - - - - - int - - - - - - InlineArray(2) - - int - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/VarDeclarationTest.cs deleted file mode 100644 index 1345f4e7..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlDefaultWindows/VarDeclarationTest.cs +++ /dev/null @@ -1,543 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlDefaultWindows_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@" - - - - - Guid - - new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46) - - - - - -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - {expectedManagedValue} - - - - {expectedManagedType} - - {expectedManagedValue} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@" - - - - - int - - 0 + 1 - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - byte[] - - ""Test\0\\\r\n\t\""""u8.ToArray() - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - byte[] - - ""Test\0\\\r\n\t\""""u8.ToArray() - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@" - - - - - int - - - - (int)(0x80000000) - - - - - - int - - - - (int)(0x80000000) - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@" - - - - - uint - - - - (uint)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))) - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@" - - - - - int* - - - ((int*)(-1)) - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@" - - - - - int* - - - - (int*)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@" - - - - - int[][] - - new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))) - - - - - - -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/CXXMethodDeclarationTest.cs deleted file mode 100644 index 4f53a63d..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,477 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlLatestUnix_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; - - var expectedOutputContents = $@" - - - - - int* - - MyStruct* - - - int* - - null - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = Environment.Is64BitProcess - ? "?MyVoidMethod@MyStruct@@QEAAXXZ" - : "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - MyStruct* - - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@" - - - - - void** - - - int - - int - - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - int - - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl* - - - int - - int - - - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - int - - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - int - - - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - - delegate* unmanaged[Thiscall]<MyStruct*, int, int> - - - delegate* unmanaged[Thiscall]<MyStruct*, int> - - - delegate* unmanaged[Thiscall]<MyStruct*, int, int, int> - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl<MyStruct>* - - - int - - int - - - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - int - - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - int - - - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - - int - - int - - - - int - - - int - - int - - - int - - - - - - delegate* unmanaged[Thiscall]<TSelf*, int, int> - - - delegate* unmanaged[Thiscall]<TSelf*, int> - - - delegate* unmanaged[Thiscall]<TSelf*, int, int, int> - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@" - - - - - void - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - sbyte - - return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - void* - - return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - sbyte - - return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - void* - - return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/DeprecatedToObsoleteTest.cs deleted file mode 100644 index 36d7c219..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,537 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlLatestUnix_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - Obsolete - int - - int - - - - Obsolete(""This is obsolete."") - int - - int - - - - int - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@" - - - - - int - - 0 - - - - Obsolete - int - - 0 - - - - Obsolete(""This is obsolete."") - int - - 0 - - - - int - - 0 - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - Obsolete - void - - - - Obsolete(""This is obsolete."") - void - - - - void - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@" - - - - - int - return 0; - - - Obsolete - int - return 0; - - - Obsolete(""This is obsolete."") - int - return 0; - - - int - return 0; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - - Obsolete - delegate* unmanaged[Cdecl]<void> - - - - - Obsolete(""This is obsolete."") - delegate* unmanaged[Cdecl]<void> - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @" - - - - - void - - - Obsolete - void - - - Obsolete(""This is obsolete."") - void - - - void - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/DigitsSeparatorTest.cs deleted file mode 100644 index a50d5265..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/DigitsSeparatorTest.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.XmlLatestUnix; - -[Platform("unix")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {type} - - {expectedValue} - - - - - -"; - return ValidateGeneratedXmlLatestUnixBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs deleted file mode 100644 index 6161c739..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/EnumDeclarationTest.cs +++ /dev/null @@ -1,730 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlLatestUnix_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum : int -{ - MyEnum_Value1, - MyEnum_Value2, - MyEnum_Value3, -} MyEnum; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @" - - - - Flags - int - - int - - 1 - - - - - int - - int - - 1 - - - - - -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - (int)(MyEnum)(10) - - - - int - - (int)(MyEnum)(MyEnum_Value0) - - - - int - - ((int)(MyEnum)(10)) + MyEnum_Value1 - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 10 - - - - - int - - int - - MyEnum1_Value0 - - - - int - - MyEnum1_Value0 + (int)(MyEnum1)(10) - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - int - - 0x80000000 - - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - - - -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - 0x80000000 - - - - - -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - MyEnum1_Value1 - - - - - - uint - - 1 - - - - - -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @" - - - - - uint - - 1 - - - - int - - (int)(MyEnum1_Value1) + 1 - - - - - -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index 861c27f3..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,1992 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlLatestUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - - int - - return pData[index]; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - bool - - - bool - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - while (true) - {{ - break; - }} - - return 0; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = $@" - - - - - void - - - - void - MyCalledFunction(); - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = $@" - - - - - void - - int - - - int - - - - - void - MyCalledFunction(0, 1); - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 1: - case 2: - {{ - return 3; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 2: - case 3: - {{ - return 5; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = $@" - - - - int - - int - - - int - - - int - - - - - int - - MyEnum - - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = $@" - - - - - int - - bool - - - int - - - int - - return condition ? lhs : rhs; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - while (true) - { - continue; - } - - return 0; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - void* - - void* - - return input; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStructA*, void>)(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); - - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStructB*, void>)(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); - - - - - - MyStructB* - - MyStructA* - - return (MyStructB*)(input); - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @" - - - - - int - int x = 0; - int y = 1, z = 2; - - return x + y + z; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - - return rhs; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - - bool - - - int - - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @" - - - - - void - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @" - - - - - float - - - float - - - float - - - float - - - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - int - - MyStruct - - return instance.value; - - - int - - MyStruct* - - return instance->value; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - bool - - MyStruct* - - - MyStruct* - - return lhs->value == rhs->value; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @" - - - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - return {value}; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - double - return {value}; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - float - return {value}; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @" - - - - - void - return; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - return -1; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.a; - - - - - int - - - - - - void - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - - - MyStruct - MyStruct myStruct = new MyStruct(); - - return myStruct; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @" - - - - - int* - - int - - return &value; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - return *value; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @" - - - - - bool - - bool - - return !value; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return value{opcode}; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return {opcode}value; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index d3222b5d..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlLatestUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @" - - - - - void - - float* - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @" - - - - - void - - delegate* unmanaged[Cdecl]<void> - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@" - - - - - void - - MyTemplate<{expectedManagedType}> - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@" - - - - - MyTemplate<IntPtr> - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @" - - - - - void - - float - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionPointerDeclarationTest.cs deleted file mode 100644 index 6c03dc0c..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlLatestUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Stdcall]<void> - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs deleted file mode 100644 index 5fd0fe60..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/StructDeclarationTest.cs +++ /dev/null @@ -1,1951 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlLatestUnix_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - return ref Unsafe.Add(ref e0, index); - - - - Span<{expectedManagedType}> - - int - - MemoryMarshal.CreateSpan(ref e0, length); - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - return (byte)((_bitfield2 >> 22) & 0x1u); - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - - - - int - - return (int)(_bitfield2 << 8) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - - - - int - - return (int)(_bitfield2 << 7) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - NativeBitfield(""o0_b0_24"", offset: 0, length: 24) - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - NativeBitfield(""o4_b0_16"", offset: 0, length: 16) - NativeBitfield(""o4_b16_3"", offset: 16, length: 3) - NativeBitfield(""o4_b19_3"", offset: 19, length: 3) - NativeBitfield(""o4_b22_1"", offset: 22, length: 1) - NativeBitfield(""o4_b23_1"", offset: 23, length: 1) - NativeBitfield(""o4_b24_1"", offset: 24, length: 1) - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - return (byte)((_bitfield2 >> 22) & 0x1u); - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - - - - int - - return (int)(_bitfield2 << 8) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - - - - int - - return (int)(_bitfield2 << 7) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - NativeBitfield(""o8_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - NativeBitfield(""o0_b1_1"", offset: 1, length: 1) - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - - void - - - - -"; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(2 * 1 * 3 * 4) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(2 * 1 * 3 * 4) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Unix doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Struct - - - ref {expectedManagedType} - - return ref Anonymous.z; - - - - ref _Anonymous_e__Struct._w_e__Struct - - return ref Anonymous.w; - - - - ref MyUnion - - return ref Anonymous.u; - - - - Span<{expectedManagedType}> - - return Anonymous.buffer1; - - - - Span<MyUnion> - - return Anonymous.buffer2; - - - - - {expectedManagedType} - - - _w_e__Struct - - - MyUnion - - - {expectedManagedType} - - - MyUnion - - - - {expectedManagedType} - - - - InlineArray(4) - - {expectedManagedType} - - - - InlineArray(4) - - MyUnion - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.z; - - - - ref int - - return ref Anonymous.Anonymous1.w; - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Struct - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; - - var expectedOutputContents = $@" - - - - - uint - - - void* - - - uint - - - - - uint - - - void* - - - uint - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Struct - - - ref double - - return ref Anonymous.a; - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @" - - - - - void - - - - - - void - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - int - - - int - - - - -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"typedef int size_t; - -struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @" - - - - - nuint - - - InlineArray(2) - - nuint - - - - - -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @" - - - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - _MyArray_e__Struct - - - ref int - - return ref Anonymous.First; - - - - - int - - - - - int - - - - InlineArray(2) - - _MyArray_e__Struct - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.Anonymous1.Anonymous2.Value1; - - - - ref int - - return ref Anonymous.Anonymous1.Anonymous3.Value2; - - - - - _Anonymous1_e__Struct - - - - _Anonymous2_e__Struct - - - _Anonymous3_e__Struct - - - - int - - - - - int - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs deleted file mode 100644 index 16ab4377..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/UnionDeclarationTest.cs +++ /dev/null @@ -1,1311 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlLatestUnix_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; - - var expectedOutputContents = $@" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - return (byte)((_bitfield2 >> 22) & 0x1u); - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - - - - int - - return (int)(_bitfield2 << 8) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - - - - int - - return (int)(_bitfield2 << 7) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(2 * 1 * 3 * 4) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(2 * 1 * 3 * 4) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Unix doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Union - - - ref {expectedManagedType} - - return ref Anonymous.a; - - - - ref MyStruct - - return ref Anonymous.s; - - - - Span<{expectedManagedType}> - - return Anonymous.buffer; - - - - - {expectedManagedType} - - - MyStruct - - - {expectedManagedType} - - - InlineArray(4) - - {expectedManagedType} - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Union - - - ref int - - return ref Anonymous.z; - - - - ref int - - return ref Anonymous.Anonymous1.w; - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Union - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Union - - - ref double - - return ref Anonymous.a; - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@" - - - - - nint - - - _Anonymous_e__Struct - - - ref nint - - return ref Anonymous.First; - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct - - return ref Anonymous.Anonymous.A; - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct - - return ref Anonymous.Anonymous.B; - - - - - nint - - - _Anonymous_e__Union - - - - _A_e__Struct - - - _B_e__Struct - - - - nint - - - - - nint - - - - - - InlineArray(2) - - nint - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs deleted file mode 100644 index 3db3bb34..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestUnix/VarDeclarationTest.cs +++ /dev/null @@ -1,543 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlLatestUnix_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@" - - - - - Guid - - new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46) - - - - - -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - {expectedManagedValue} - - - - {expectedManagedType} - - {expectedManagedValue} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@" - - - - - int - - 0 + 1 - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<uint> - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - uint[] - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - ReadOnlySpan<uint> - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - byte[] - - ""Test\0\\\r\n\t\""""u8.ToArray() - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<uint> - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - uint[] - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - ReadOnlySpan<uint> - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - byte[] - - ""Test\0\\\r\n\t\""""u8.ToArray() - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@" - - - - - nint - - - - (nint)(0x80000000) - - - - - - int - - - - (int)(0x80000000) - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@" - - - - - uint - - - - (uint)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))) - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@" - - - - - int* - - - ((int*)(-1)) - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@" - - - - - int* - - - - (int*)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@" - - - - - int[][] - - new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }} - - - - - -"; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))) - - - - - - -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlLatestUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/CXXMethodDeclarationTest.cs deleted file mode 100644 index bcc3b0ce..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,477 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlLatestWindows_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; - - var expectedOutputContents = $@" - - - - - int* - - MyStruct* - - - int* - - null - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = Environment.Is64BitProcess - ? "?MyVoidMethod@MyStruct@@QEAAXXZ" - : "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - MyStruct* - - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@" - - - - - void** - - - int - - int - - - int - - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int, int>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl* - - - int - - int - - - int - - - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - int - - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - - delegate* unmanaged[Thiscall]<MyStruct*, int, int, int> - - - delegate* unmanaged[Thiscall]<MyStruct*, int> - - - delegate* unmanaged[Thiscall]<MyStruct*, int, int> - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl<MyStruct>* - - - int - - int - - - int - - - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - int - - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - - int - - int - - - int - - - - int - - - int - - int - - - - - - delegate* unmanaged[Thiscall]<TSelf*, int, int, int> - - - delegate* unmanaged[Thiscall]<TSelf*, int> - - - delegate* unmanaged[Thiscall]<TSelf*, int, int> - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@" - - - - - void - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - sbyte - - return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - void* - - return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - sbyte - - return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - void* - - return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/DeprecatedToObsoleteTest.cs deleted file mode 100644 index f6de9033..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,537 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlLatestWindows_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - Obsolete - int - - int - - - - Obsolete(""This is obsolete."") - int - - int - - - - int - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@" - - - - - int - - 0 - - - - Obsolete - int - - 0 - - - - Obsolete(""This is obsolete."") - int - - 0 - - - - int - - 0 - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - Obsolete - void - - - - Obsolete(""This is obsolete."") - void - - - - void - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@" - - - - - int - return 0; - - - Obsolete - int - return 0; - - - Obsolete(""This is obsolete."") - int - return 0; - - - int - return 0; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - - Obsolete - delegate* unmanaged[Cdecl]<void> - - - - - Obsolete(""This is obsolete."") - delegate* unmanaged[Cdecl]<void> - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @" - - - - - void - - - Obsolete - void - - - Obsolete(""This is obsolete."") - void - - - void - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/DigitsSeparatorTest.cs deleted file mode 100644 index 0193daf6..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/DigitsSeparatorTest.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.XmlLatestWindows; - -[Platform("win")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {type} - - {expectedValue} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs deleted file mode 100644 index cb6bf487..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/EnumDeclarationTest.cs +++ /dev/null @@ -1,730 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlLatestWindows_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum : int -{ - MyEnum_Value1, - MyEnum_Value2, - MyEnum_Value3, -} MyEnum; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @" - - - - Flags - int - - int - - 1 - - - - - int - - int - - 1 - - - - - -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - (int)(MyEnum)(10) - - - - int - - (int)(MyEnum)(MyEnum_Value0) - - - - int - - ((int)(MyEnum)(10)) + MyEnum_Value1 - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 10 - - - - - int - - int - - MyEnum1_Value0 - - - - int - - MyEnum1_Value0 + (int)(MyEnum1)(10) - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - int - - 0x80000000 - - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - - - -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - 0x80000000 - - - - - -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - MyEnum1_Value1 - - - - - - int - - 1 - - - - - -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @" - - - - - int - - 1 - - - - int - - (int)(MyEnum1_Value1) + 1 - - - - - -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index bdca15de..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,1992 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlLatestWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - - int - - return pData[index]; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - bool - - - bool - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - while (true) - {{ - break; - }} - - return 0; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = $@" - - - - - void - - - - void - MyCalledFunction(); - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = $@" - - - - - void - - int - - - int - - - - - void - MyCalledFunction(0, 1); - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 1: - case 2: - {{ - return 3; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 2: - case 3: - {{ - return 5; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = $@" - - - - int - - int - - - int - - - int - - - - - int - - MyEnum - - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = $@" - - - - - int - - bool - - - int - - - int - - return condition ? lhs : rhs; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - while (true) - { - continue; - } - - return 0; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - void* - - void* - - return input; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStructA*, void>)(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); - - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStructB*, void>)(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); - - - - - - MyStructB* - - MyStructA* - - return (MyStructB*)(input); - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @" - - - - - int - int x = 0; - int y = 1, z = 2; - - return x + y + z; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - - return rhs; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - - bool - - - int - - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @" - - - - - void - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @" - - - - - float - - - float - - - float - - - float - - - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - int - - MyStruct - - return instance.value; - - - int - - MyStruct* - - return instance->value; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - bool - - MyStruct* - - - MyStruct* - - return lhs->value == rhs->value; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @" - - - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - return {value}; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - double - return {value}; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - float - return {value}; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @" - - - - - void - return; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - return -1; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.a; - - - - - int - - - - - - void - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - - - MyStruct - MyStruct myStruct = new MyStruct(); - - return myStruct; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @" - - - - - int* - - int - - return &value; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - return *value; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @" - - - - - bool - - bool - - return !value; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return value{opcode}; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return {opcode}value; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index 83365118..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlLatestWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @" - - - - - void - - float* - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @" - - - - - void - - delegate* unmanaged[Cdecl]<void> - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@" - - - - - void - - MyTemplate<{expectedManagedType}> - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@" - - - - - MyTemplate<IntPtr> - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @" - - - - - void - - float - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionPointerDeclarationTest.cs deleted file mode 100644 index 68f182af..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlLatestWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Stdcall]<void> - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs deleted file mode 100644 index b79079b9..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/StructDeclarationTest.cs +++ /dev/null @@ -1,1961 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlLatestWindows_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - return ref Unsafe.Add(ref e0, index); - - - - Span<{expectedManagedType}> - - int - - MemoryMarshal.CreateSpan(ref e0, length); - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - - byte - - return (byte)(_bitfield3 & 0x1u); - - - - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - - - - int - - - int - - return (_bitfield4 << 31) >> 31; - - - - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - - - - int - - return (_bitfield4 << 30) >> 31; - - - - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - NativeBitfield(""o0_b0_24"", offset: 0, length: 24) - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - NativeBitfield(""o4_b0_16"", offset: 0, length: 16) - NativeBitfield(""o4_b16_3"", offset: 16, length: 3) - NativeBitfield(""o4_b19_3"", offset: 19, length: 3) - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - NativeBitfield(""o8_b0_1"", offset: 0, length: 1) - byte - - - byte - - return (byte)(_bitfield3 & 0x1u); - - - - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - - - - NativeBitfield(""o12_b0_1"", offset: 0, length: 1) - NativeBitfield(""o12_b1_1"", offset: 1, length: 1) - int - - - int - - return (_bitfield4 << 31) >> 31; - - - - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - - - - int - - return (_bitfield4 << 30) >> 31; - - - - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - NativeBitfield(""o8_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - NativeBitfield(""o0_b1_1"", offset: 1, length: 1) - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - - void - - - - -"; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(2 * 1 * 3 * 4) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(2 * 1 * 3 * 4) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Struct - - - ref {expectedManagedType} - - return ref Anonymous.z; - - - - ref _Anonymous_e__Struct._w_e__Struct - - return ref Anonymous.w; - - - - ref MyUnion - - return ref Anonymous.u; - - - - Span<{expectedManagedType}> - - return Anonymous.buffer1; - - - - Span<MyUnion> - - return Anonymous.buffer2; - - - - - {expectedManagedType} - - - _w_e__Struct - - - MyUnion - - - {expectedManagedType} - - - MyUnion - - - - {expectedManagedType} - - - - InlineArray(4) - - {expectedManagedType} - - - - InlineArray(4) - - MyUnion - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.z; - - - - ref int - - return ref Anonymous.Anonymous1.w; - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Struct - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; - - var expectedOutputContents = $@" - - - - - uint - - - void* - - - uint - - - - - uint - - - void* - - - uint - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Struct - - - ref double - - return ref Anonymous.a; - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @" - - - - - void - - - - - - void - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - int - - - int - - - - -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @" - - - - - nuint - - - InlineArray(2) - - nuint - - - - - -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @" - - - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - _MyArray_e__Struct - - - ref int - - return ref Anonymous.First; - - - - - int - - - - - int - - - - InlineArray(2) - - _MyArray_e__Struct - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.Anonymous1.Anonymous2.Value1; - - - - ref int - - return ref Anonymous.Anonymous1.Anonymous3.Value2; - - - - - _Anonymous1_e__Struct - - - - _Anonymous2_e__Struct - - - _Anonymous3_e__Struct - - - - int - - - - - int - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs deleted file mode 100644 index dcf645cf..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/UnionDeclarationTest.cs +++ /dev/null @@ -1,1317 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlLatestWindows_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; - - var expectedOutputContents = $@" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - - byte - - return (byte)(_bitfield3 & 0x1u); - - - - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - - - - int - - - int - - return (_bitfield4 << 31) >> 31; - - - - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - - - - int - - return (_bitfield4 << 30) >> 31; - - - - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(2 * 1 * 3 * 4) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(2 * 1 * 3 * 4) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Union - - - ref {expectedManagedType} - - return ref Anonymous.a; - - - - ref MyStruct - - return ref Anonymous.s; - - - - Span<{expectedManagedType}> - - return Anonymous.buffer; - - - - - {expectedManagedType} - - - MyStruct - - - {expectedManagedType} - - - InlineArray(4) - - {expectedManagedType} - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Union - - - ref int - - return ref Anonymous.z; - - - - ref int - - return ref Anonymous.Anonymous1.w; - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Union - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Union - - - ref double - - return ref Anonymous.a; - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@" - - - - - int - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.First; - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct - - return ref Anonymous.Anonymous.A; - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct - - return ref Anonymous.Anonymous.B; - - - - - int - - - _Anonymous_e__Union - - - - _A_e__Struct - - - _B_e__Struct - - - - int - - - - - int - - - - - - InlineArray(2) - - int - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs deleted file mode 100644 index ccb99e7c..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlLatestWindows/VarDeclarationTest.cs +++ /dev/null @@ -1,544 +0,0 @@ - -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlLatestWindows_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@" - - - - - Guid - - new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46) - - - - - -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - {expectedManagedValue} - - - - {expectedManagedType} - - {expectedManagedValue} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@" - - - - - int - - 0 + 1 - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - byte[] - - ""Test\0\\\r\n\t\""""u8.ToArray() - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - byte[] - - ""Test\0\\\r\n\t\""""u8.ToArray() - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@" - - - - - int - - - - (int)(0x80000000) - - - - - - int - - - - (int)(0x80000000) - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@" - - - - - uint - - - - (uint)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))) - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@" - - - - - int* - - - ((int*)(-1)) - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@" - - - - - int* - - - - (int*)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@" - - - - - int[][] - - new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }} - - - - - -"; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))) - - - - - - -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlLatestWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/CXXMethodDeclarationTest.cs deleted file mode 100644 index a7ce8031..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,475 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlPreviewUnix_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8$MyTemplateDoWorkEv" : "_ZN10MyTemplateIiE6DoWorkEPi"; - var expectedOutputContents = $@" - - - - - int* - - MyStruct* - - - int* - - null - - - - - - -"; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = Environment.Is64BitProcess - ? "?MyVoidMethod@MyStruct@@QEAAXXZ" - : "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - MyStruct* - - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@" - - - - - void** - - - int - - int - - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - int - - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl* - - - int - - int - - - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - int - - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - int - - - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - - delegate* unmanaged[Thiscall]<MyStruct*, int, int> - - - delegate* unmanaged[Thiscall]<MyStruct*, int> - - - delegate* unmanaged[Thiscall]<MyStruct*, int, int, int> - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl<MyStruct>* - - - int - - int - - - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - int - - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - int - - - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - - int - - int - - - - int - - - int - - int - - - int - - - - - - delegate* unmanaged[Thiscall]<TSelf*, int, int> - - - delegate* unmanaged[Thiscall]<TSelf*, int> - - - delegate* unmanaged[Thiscall]<TSelf*, int, int, int> - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@" - - - - - void - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - sbyte - - return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - void* - - return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - sbyte - - return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - void* - - return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/DeprecatedToObsoleteTest.cs deleted file mode 100644 index 4a33ede7..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,537 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlPreviewUnix_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - Obsolete - int - - int - - - - Obsolete(""This is obsolete."") - int - - int - - - - int - - int - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@" - - - - - int - - 0 - - - - Obsolete - int - - 0 - - - - Obsolete(""This is obsolete."") - int - - 0 - - - - int - - 0 - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - Obsolete - void - - - - Obsolete(""This is obsolete."") - void - - - - void - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@" - - - - - int - return 0; - - - Obsolete - int - return 0; - - - Obsolete(""This is obsolete."") - int - return 0; - - - int - return 0; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - - Obsolete - delegate* unmanaged[Cdecl]<void> - - - - - Obsolete(""This is obsolete."") - delegate* unmanaged[Cdecl]<void> - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @" - - - - - void - - - Obsolete - void - - - Obsolete(""This is obsolete."") - void - - - void - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/DigitsSeparatorTest.cs deleted file mode 100644 index ff12778e..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/DigitsSeparatorTest.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.XmlPreviewUnix; - -[Platform("unix")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {type} - - {expectedValue} - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs deleted file mode 100644 index cb00d940..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/EnumDeclarationTest.cs +++ /dev/null @@ -1,730 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlPreviewUnix_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum : int -{ - MyEnum_Value1, - MyEnum_Value2, - MyEnum_Value3, -} MyEnum; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @" - - - - Flags - int - - int - - 1 - - - - - int - - int - - 1 - - - - - -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - (int)(MyEnum)(10) - - - - int - - (int)(MyEnum)(MyEnum_Value0) - - - - int - - ((int)(MyEnum)(10)) + MyEnum_Value1 - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 10 - - - - - int - - int - - MyEnum1_Value0 - - - - int - - MyEnum1_Value0 + (int)(MyEnum1)(10) - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - int - - 0x80000000 - - - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - - - -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - 0x80000000 - - - - - -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - MyEnum1_Value1 - - - - - - uint - - 1 - - - - - -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @" - - - - - uint - - 1 - - - - int - - (int)(MyEnum1_Value1) + 1 - - - - - -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index 790a437c..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,1992 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlPreviewUnix_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - - int - - return pData[index]; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - bool - - - bool - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - while (true) - {{ - break; - }} - - return 0; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = $@" - - - - - void - - - - void - MyCalledFunction(); - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = $@" - - - - - void - - int - - - int - - - - - void - MyCalledFunction(0, 1); - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 1: - case 2: - {{ - return 3; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 2: - case 3: - {{ - return 5; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = $@" - - - - int - - int - - - int - - - int - - - - - int - - MyEnum - - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = $@" - - - - - int - - bool - - - int - - - int - - return condition ? lhs : rhs; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - while (true) - { - continue; - } - - return 0; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - void* - - void* - - return input; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStructA*, void>)(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); - - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStructB*, void>)(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); - - - - - - MyStructB* - - MyStructA* - - return (MyStructB*)(input); - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @" - - - - - int - int x = 0; - int y = 1, z = 2; - - return x + y + z; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - - return rhs; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - - bool - - - int - - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @" - - - - - void - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @" - - - - - float - - - float - - - float - - - float - - - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - int - - MyStruct - - return instance.value; - - - int - - MyStruct* - - return instance->value; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - bool - - MyStruct* - - - MyStruct* - - return lhs->value == rhs->value; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @" - - - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - return {value}; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - double - return {value}; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - float - return {value}; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @" - - - - - void - return; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - return -1; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.a; - - - - - int - - - - - - void - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - - - MyStruct - MyStruct myStruct = new MyStruct(); - - return myStruct; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @" - - - - - int* - - int - - return &value; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - return *value; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @" - - - - - bool - - bool - - return !value; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return value{opcode}; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return {opcode}value; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index 7816a51b..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlPreviewUnix_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @" - - - - - void - - float* - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @" - - - - - void - - delegate* unmanaged[Cdecl]<void> - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@" - - - - - void - - MyTemplate<{expectedManagedType}> - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@" - - - - - MyTemplate<IntPtr> - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @" - - - - - void - - float - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionPointerDeclarationTest.cs deleted file mode 100644 index 5ccea7ec..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlPreviewUnix_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Stdcall]<void> - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs deleted file mode 100644 index 4c4c8307..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/StructDeclarationTest.cs +++ /dev/null @@ -1,1949 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlPreviewUnix_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - return ref Unsafe.Add(ref e0, index); - - - - Span<{expectedManagedType}> - - int - - MemoryMarshal.CreateSpan(ref e0, length); - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - return (byte)((_bitfield2 >> 22) & 0x1u); - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - - - - int - - return (int)(_bitfield2 << 8) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - - - - int - - return (int)(_bitfield2 << 7) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o4_b22_1 : 1; - int o4_b23_1 : 1; - int o4_b24_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - NativeBitfield(""o0_b0_24"", offset: 0, length: 24) - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - NativeBitfield(""o4_b0_16"", offset: 0, length: 16) - NativeBitfield(""o4_b16_3"", offset: 16, length: 3) - NativeBitfield(""o4_b19_3"", offset: 19, length: 3) - NativeBitfield(""o4_b22_1"", offset: 22, length: 1) - NativeBitfield(""o4_b23_1"", offset: 23, length: 1) - NativeBitfield(""o4_b24_1"", offset: 24, length: 1) - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - return (byte)((_bitfield2 >> 22) & 0x1u); - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - - - - int - - return (int)(_bitfield2 << 8) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - - - - int - - return (int)(_bitfield2 << 7) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - NativeBitfield(""o8_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - NativeBitfield(""o0_b1_1"", offset: 1, length: 1) - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - - void - - - - -"; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(2 * 1 * 3 * 4) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(2 * 1 * 3 * 4) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Unix doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Struct - - - ref {expectedManagedType} - - return ref Anonymous.z; - - - - ref _Anonymous_e__Struct._w_e__Struct - - return ref Anonymous.w; - - - - ref MyUnion - - return ref Anonymous.u; - - - - Span<{expectedManagedType}> - - return Anonymous.buffer1; - - - - Span<MyUnion> - - return Anonymous.buffer2; - - - - - {expectedManagedType} - - - _w_e__Struct - - - MyUnion - - - {expectedManagedType} - - - MyUnion - - - - {expectedManagedType} - - - - InlineArray(4) - - {expectedManagedType} - - - - InlineArray(4) - - MyUnion - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.z; - - - - ref int - - return ref Anonymous.Anonymous1.w; - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Struct - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; - - var expectedOutputContents = $@" - - - - - uint - - - void* - - - uint - - - - - uint - - - void* - - - uint - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Struct - - - ref double - - return ref Anonymous.a; - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @" - - - - - void - - - - - - void - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - int - - - int - - - - -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"typedef int size_t; - -struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @" - - - - - nuint - - - InlineArray(2) - - nuint - - - - - -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @" - - - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct;"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - _MyArray_e__Struct - - - ref int - - return ref Anonymous.First; - - - - - int - - - - - int - - - - InlineArray(2) - - _MyArray_e__Struct - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct;"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.Anonymous1.Anonymous2.Value1; - - - - ref int - - return ref Anonymous.Anonymous1.Anonymous3.Value2; - - - - - _Anonymous1_e__Struct - - - - _Anonymous2_e__Struct - - - _Anonymous3_e__Struct - - - - int - - - - - int - - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs deleted file mode 100644 index 11c40cec..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/UnionDeclarationTest.cs +++ /dev/null @@ -1,1311 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlPreviewUnix_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; - - var expectedOutputContents = $@" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - return (byte)((_bitfield2 >> 22) & 0x1u); - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 22)) | (uint)((value & 0x1u) << 22); - - - - int - - return (int)(_bitfield2 << 8) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 23)) | (uint)((value & 0x1) << 23); - - - - int - - return (int)(_bitfield2 << 7) >> 31; - - - - _bitfield2 = (_bitfield2 & ~(0x1u << 24)) | (uint)((value & 0x1) << 24); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(2 * 1 * 3 * 4) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(2 * 1 * 3 * 4) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Unix doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Union - - - ref {expectedManagedType} - - return ref Anonymous.a; - - - - ref MyStruct - - return ref Anonymous.s; - - - - Span<{expectedManagedType}> - - return Anonymous.buffer; - - - - - {expectedManagedType} - - - MyStruct - - - {expectedManagedType} - - - InlineArray(4) - - {expectedManagedType} - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Union - - - ref int - - return ref Anonymous.z; - - - - ref int - - return ref Anonymous.Anonymous1.w; - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Union - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Union - - - ref double - - return ref Anonymous.a; - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@" - - - - - nint - - - _Anonymous_e__Struct - - - ref nint - - return ref Anonymous.First; - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct - - return ref Anonymous.Anonymous.A; - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct - - return ref Anonymous.Anonymous.B; - - - - - nint - - - _Anonymous_e__Union - - - - _A_e__Struct - - - _B_e__Struct - - - - nint - - - - - nint - - - - - - InlineArray(2) - - nint - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs deleted file mode 100644 index 19dc457c..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewUnix/VarDeclarationTest.cs +++ /dev/null @@ -1,543 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("unix")] -public sealed class XmlPreviewUnix_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@" - - - - - Guid - - new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46) - - - - - -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - {expectedManagedValue} - - - - {expectedManagedType} - - {expectedManagedValue} - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@" - - - - - int - - 0 + 1 - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<uint> - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - uint[] - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - ReadOnlySpan<uint> - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - byte[] - - ""Test\0\\\r\n\t\""""u8.ToArray() - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<uint> - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - uint[] - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - ReadOnlySpan<uint> - - [0x00000054, 0x00000065, 0x00000073, 0x00000074, 0x00000000, 0x0000005C, 0x0000000D, 0x0000000A, 0x00000009, 0x00000022, 0x00000000] - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - byte[] - - ""Test\0\\\r\n\t\""""u8.ToArray() - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@" - - - - - nint - - - - (nint)(0x80000000) - - - - - - int - - - - (int)(0x80000000) - - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@" - - - - - uint - - - - (uint)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(((nuint)(1) << 31) | ((nuint)(2) << 16) | ((nuint)(3)))) - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@" - - - - - int* - - - ((int*)(-1)) - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@" - - - - - int* - - - - (int*)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@" - - - - - int[][] - - new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }} - - - - - -"; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))) - - - - - - -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlPreviewUnixBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/CXXMethodDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/CXXMethodDeclarationTest.cs deleted file mode 100644 index 84a3add5..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/CXXMethodDeclarationTest.cs +++ /dev/null @@ -1,476 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlPreviewWindows_CXXMethodDeclarationTest : CXXMethodDeclarationXmlTest -{ - protected override Task DefaultParameterInheritedFromTemplateTestImpl() - { - // NOTE: This is a regression test where a struct inherits a function from a template with a default parameter. - const string InputContents = @"template -struct MyTemplate -{ - int* DoWork(int* value = nullptr) - { - return value; - } -}; - -struct MyStruct : public MyTemplate -{}; -"; - - var entryPoint = Environment.Is64BitProcess ? "?DoWork@?$MyTemplate@H@@QEAAPEAHPEAH@Z" : "?DoWork@?$MyTemplate@H@@QEAPEHPEH@Z"; - - var expectedOutputContents = $@" - - - - - int* - - MyStruct* - - - int* - - null - - - - - - -"; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task InstanceTestImpl() - { - var inputContents = @"struct MyStruct -{ - void MyVoidMethod(); - - int MyInt32Method() - { - return 0; - } - - void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN8MyStruct12MyVoidMethodEv" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = Environment.Is64BitProcess - ? "?MyVoidMethod@MyStruct@@QEAAXXZ" - : "?MyVoidMethod@MyStruct@@QAEXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - MyStruct* - - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var expectedOutputContents = $@" - - - - - void** - - - int - - int - - - int - - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int, int>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordVirtualWithExplicitVtblTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl* - - - int - - int - - - int - - - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - int - - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - - delegate* unmanaged[Thiscall]<MyStruct*, int, int, int> - - - delegate* unmanaged[Thiscall]<MyStruct*, int> - - - delegate* unmanaged[Thiscall]<MyStruct*, int, int> - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); - } - - protected override Task NewKeywordVirtualWithExplicitVtblAndMarkerInterfaceTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual int GetType(int obj) = 0; - virtual int GetType() = 0; - virtual int GetType(int objA, int objB) = 0; -};"; - - var nativeCallConv = ""; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && !Environment.Is64BitProcess) - { - nativeCallConv = " __attribute__((thiscall))"; - } - - var expectedOutputContents = $@" - - - - - Vtbl<MyStruct>* - - - int - - int - - - int - - - return lpVtbl->GetType((MyStruct*)Unsafe.AsPointer(ref this), objA, objB); - - - - int - - return lpVtbl->GetType1((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - int - - - return lpVtbl->GetType2((MyStruct*)Unsafe.AsPointer(ref this), obj); - - - - - int - - int - - - int - - - - int - - - int - - int - - - - - - delegate* unmanaged[Thiscall]<TSelf*, int, int, int> - - - delegate* unmanaged[Thiscall]<TSelf*, int> - - - delegate* unmanaged[Thiscall]<TSelf*, int, int> - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); - } - - protected override Task StaticTestImpl() - { - var inputContents = @"struct MyStruct -{ - static void MyVoidMethod(); - - static int MyInt32Method() - { - return 0; - } - - static void* MyVoidStarMethod() - { - return nullptr; - } -}; -"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "?MyVoidMethod@MyStruct@@SAXXZ" : "_ZN8MyStruct12MyVoidMethodEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - entryPoint = $"_{entryPoint}"; - } - - var expectedOutputContents = $@" - - - - - void - - - int - return 0; - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - sbyte - - return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - void* - - return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task VirtualWithVtblIndexAttributeTestImpl() - { - var inputContents = @"struct MyStruct -{ - virtual void MyVoidMethod() = 0; - - virtual signed char MyInt8Method() - { - return 0; - } - - virtual int MyInt32Method(); - - virtual void* MyVoidStarMethod() = 0; -}; -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStruct*, void>)(lpVtbl[0]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - sbyte - - return ((delegate* unmanaged[Thiscall]<MyStruct*, sbyte>)(lpVtbl[1]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - int - - return ((delegate* unmanaged[Thiscall]<MyStruct*, int>)(lpVtbl[2]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - void* - - return ((delegate* unmanaged[Thiscall]<MyStruct*, void*>)(lpVtbl[3]))((MyStruct*)Unsafe.AsPointer(ref this)); - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateVtblIndexAttribute); - } - - protected override Task ValidateBindingsAsync(string inputContents, string expectedOutputContents) => ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/DeprecatedToObsoleteTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/DeprecatedToObsoleteTest.cs deleted file mode 100644 index 7bc36051..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/DeprecatedToObsoleteTest.cs +++ /dev/null @@ -1,537 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlPreviewWindows_DeprecatedToObsoleteTest : DeprecatedToObsoleteTest -{ - protected override Task SimpleStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StructDeclImpl() - { - var inputContents = $@"struct MyStruct0 -{{ - int r; -}}; - -struct [[deprecated]] MyStruct1 -{{ - int r; -}}; - -struct [[deprecated(""This is obsolete."")]] MyStruct2 -{{ - int r; -}}; - -struct MyStruct3 -{{ - int r; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleTypedefStructMembersImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - - [[deprecated]] - {nativeType} g; - - [[deprecated(""This is obsolete."")]] - {nativeType} b; - - {nativeType} a; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefStructDeclImpl() - { - var inputContents = $@"typedef struct -{{ - int r; -}} MyStruct0; - -[[deprecated]] typedef struct -{{ - int r; -}} MyStruct1; - -[[deprecated(""This is obsolete."")]] typedef struct -{{ - int r; -}} MyStruct2; - -typedef struct -{{ - int r; -}} MyStruct3; -"; - - var expectedOutputContents = $@" - - - - - int - - - - Obsolete - - int - - - - Obsolete(""This is obsolete."") - - int - - - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleEnumMembersImpl() - { - var inputContents = $@"enum MyEnum : int -{{ - MyEnum_Value0, - MyEnum_Value1 [[deprecated]], - MyEnum_Value2 [[deprecated(""This is obsolete."")]], - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - Obsolete - int - - - Obsolete(""This is obsolete."") - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task EnumDeclImpl() - { - var inputContents = $@"enum MyEnum0 : int -{{ - MyEnum_Value0, -}}; - -enum [[deprecated]] MyEnum1 : int -{{ - MyEnum_Value1, -}}; - -enum [[deprecated(""This is obsolete."")]] MyEnum2 : int -{{ - MyEnum_Value2, -}}; - - -enum MyEnum3 : int -{{ - MyEnum_Value3, -}}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - Obsolete - int - - int - - - - Obsolete(""This is obsolete."") - int - - int - - - - int - - int - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SimpleVarDeclImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@" -{nativeType} MyVariable0 = 0; - -[[deprecated]] -{nativeType} MyVariable1 = 0; - -[[deprecated(""This is obsolete."")]] -{nativeType} MyVariable2 = 0; - -{nativeType} MyVariable3 = 0;"; - - var expectedOutputContents = $@" - - - - - int - - 0 - - - - Obsolete - int - - 0 - - - - Obsolete(""This is obsolete."") - int - - 0 - - - - int - - 0 - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDeclImpl() - { - var inputContents = @" -void MyFunction0() -{ -} - -[[deprecated]] -void MyFunction1() -{ -} - -[[deprecated(""This is obsolete."")]] -void MyFunction2() -{ -} - -void MyFunction3() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - Obsolete - void - - - - Obsolete(""This is obsolete."") - void - - - - void - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InstanceFuncImpl() - { - var inputContents = @"struct MyStruct -{ - int MyFunction0() { return 0; } - - [[deprecated]] - int MyFunction1() { return 0; } - - [[deprecated(""This is obsolete."")]] - int MyFunction2() { return 0; } - - int MyFunction3() { return 0; } -};"; - - var expectedOutputContents = $@" - - - - - int - return 0; - - - Obsolete - int - return 0; - - - Obsolete(""This is obsolete."") - int - return 0; - - - int - return 0; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncPtrDeclImpl() - { - var inputContents = @" -typedef void (*Callback0)(); -[[deprecated]] typedef void (*Callback1)(); -[[deprecated(""This is obsolete."")]] typedef void (*Callback2)(); -typedef void (*Callback3)(); - -struct MyStruct0 { - Callback0 _callback; -}; -struct MyStruct1 { - Callback1 _callback; -}; -struct MyStruct2 { - Callback2 _callback; -}; -struct MyStruct3 { - Callback3 _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - - Obsolete - delegate* unmanaged[Cdecl]<void> - - - - - Obsolete(""This is obsolete."") - delegate* unmanaged[Cdecl]<void> - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FuncDllImportImpl() - { - var inputContents = @" -extern ""C"" void MyFunction0(); -extern ""C"" [[deprecated]] void MyFunction1(); -extern ""C"" [[deprecated(""This is obsolete."")]] void MyFunction2(); -extern ""C"" void MyFunction3();"; - - var expectedOutputContents = @" - - - - - void - - - Obsolete - void - - - Obsolete(""This is obsolete."") - void - - - void - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/DigitsSeparatorTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/DigitsSeparatorTest.cs deleted file mode 100644 index c8d82564..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/DigitsSeparatorTest.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests.XmlPreviewWindows; - -[Platform("win")] -public sealed class DigitsSeparatorTest : UnitTests.DigitsSeparatorTest -{ - protected override Task StaticConstExprTestImpl(string type, string nativeValue, string expectedValue) - { - var inputContents = $@"class MyClass -{{ - private: - - static constexpr {type} x = {nativeValue}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {type} - - {expectedValue} - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync( - inputContents, - expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs deleted file mode 100644 index 0f1d75a1..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/EnumDeclarationTest.cs +++ /dev/null @@ -1,730 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlPreviewWindows_EnumDeclarationTest : EnumDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicValueTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value1 = 1, - MyEnum_Value2, - MyEnum_Value3, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task ExplicitTypedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExplicitTypedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"enum MyEnum : {nativeType} -{{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}}; -"; - - var expectedOutputContents = $@" - - - - {EscapeXml(expectedManagedType)} - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - {EscapeXml(expectedManagedType)} - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = @"typedef enum _MyEnum : int -{ - MyEnum_Value1, - MyEnum_Value2, - MyEnum_Value3, -} MyEnum; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - -"; - - var remappedNames = new Dictionary { ["_MyEnum"] = "MyEnum" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task WithAttributeTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = 1, -}; -"; - - var expectedOutputContents = @" - - - - Flags - int - - int - - 1 - - - - - int - - int - - 1 - - - - - -"; - - var withAttributes = new Dictionary> - { - ["MyEnum1"] = ["Flags"] - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); - } - - protected override Task WithNamespaceTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["MyEnum1"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"] - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithNamespaceStarPlusTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 1 - - - - - int - - int - - MyEnum1_Value1 - - - - - -"; - - var withNamespaces = new Dictionary> - { - ["*"] = ["static ClangSharp.Test.MyEnum1"], - ["MyEnum2"] = ["System"] - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withNamespaces); - } - - protected override Task WithCastToEnumTypeImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0 = (MyEnum) 10, - MyEnum_Value1 = (MyEnum) MyEnum_Value0, - MyEnum_Value2 = ((MyEnum) 10) + MyEnum_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - (int)(MyEnum)(10) - - - - int - - (int)(MyEnum)(MyEnum_Value0) - - - - int - - ((int)(MyEnum)(10)) + MyEnum_Value1 - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithMultipleEnumsTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 = 10, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 = MyEnum1_Value0, - MyEnum2_Value1 = MyEnum1_Value0 + (MyEnum1) 10, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - 10 - - - - - int - - int - - MyEnum1_Value0 - - - - int - - MyEnum1_Value0 + (int)(MyEnum1)(10) - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - int - - - int - - - - int - - 0x80000000 - - - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithTypeTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - - - -"; - - var withTypes = new Dictionary { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeAndImplicitConversionTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2 = 0x80000000, -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - uint - - - uint - - 0x80000000 - - - - - -"; - - var withTypes = new Dictionary - { - ["MyEnum"] = "uint" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - uint - - uint - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithTypeStarOverrideTestImpl() - { - var inputContents = @"enum MyEnum1 : int -{ - MyEnum1_Value0 -}; - -enum MyEnum2 : int -{ - MyEnum2_Value0 -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - - - uint - - uint - - - - -"; - - var withTypes = new Dictionary - { - ["*"] = "uint", - ["MyEnum1"] = "int", - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); - } - - protected override Task WithAnonymousEnumTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -enum MyEnum2 : int -{ - MyEnum2_Value1 = MyEnum1_Value1, -}; -"; - - var expectedOutputContents = @" - - - - int - - int - - MyEnum1_Value1 - - - - - - int - - 1 - - - - - -"; - - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task WithReferenceToAnonymousEnumEnumeratorTestImpl() - { - var inputContents = @"enum -{ - MyEnum1_Value1 = 1, -}; - -const int MyEnum2_Value1 = MyEnum1_Value1 + 1; -"; - - var expectedOutputContents = @" - - - - - int - - 1 - - - - int - - (int)(MyEnum1_Value1) + 1 - - - - - -"; - var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationBodyImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationBodyImportTest.cs deleted file mode 100644 index 98a64f6a..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationBodyImportTest.cs +++ /dev/null @@ -1,1992 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlPreviewWindows_FunctionDeclarationBodyImportTest : FunctionDeclarationBodyImportTest -{ - protected override Task ArraySubscriptTestImpl() - { - var inputContents = @"int MyFunction(int* pData, int index) -{ - return pData[index]; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - - int - - return pData[index]; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl() - { - var inputContents = @"void MyFunction() -{ -} -"; - - var expectedOutputContents = @" - - - - - void - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBasicTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorCompareTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(int x, int y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - int - - - int - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BinaryOperatorBooleanTestImpl(string opcode) - { - var inputContents = $@"bool MyFunction(bool x, bool y) -{{ - return x {opcode} y; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - - bool - - - bool - - return x {EscapeXml(opcode)} y; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BreakTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - break; - } - - return 0; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - while (true) - {{ - break; - }} - - return 0; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionTestImpl() - { - var inputContents = @"void MyCalledFunction() -{ -} - -void MyFunction() -{ - MyCalledFunction(); -} -"; - - var expectedOutputContents = $@" - - - - - void - - - - void - MyCalledFunction(); - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallFunctionWithArgsTestImpl() - { - var inputContents = @"void MyCalledFunction(int x, int y) -{ -} - -void MyFunction() -{ - MyCalledFunction(0, 1); -} -"; - - var expectedOutputContents = $@" - - - - - void - - int - - - int - - - - - void - MyCalledFunction(0, 1); - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - { - return 0; - } - - case 1: - case 2: - { - return 3; - } - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 1: - case 2: - {{ - return 3; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CaseNoCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - case 0: - return 0; - - case 2: - case 3: - return 5; - } - - return -1; -} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - switch (value) - {{ - case 0: - {{ - return 0; - }} - - case 2: - case 3: - {{ - return 5; - }} - }} - - return -1; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CompareMultipleEnumTestImpl() - { - var inputContents = @"enum MyEnum : int -{ - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, -}; - -static inline int MyFunction(MyEnum x) -{ - return x == MyEnum_Value0 || - x == MyEnum_Value1 || - x == MyEnum_Value2; -} -"; - - var expectedOutputContents = $@" - - - - int - - int - - - int - - - int - - - - - int - - MyEnum - - return (x == MyEnum_Value0 || x == MyEnum_Value1 || x == MyEnum_Value2) ? 1 : 0; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalOperatorTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - return condition ? lhs : rhs; -} -"; - - var expectedOutputContents = $@" - - - - - int - - bool - - - int - - - int - - return condition ? lhs : rhs; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ContinueTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - while (true) - { - continue; - } - - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - while (true) - { - continue; - } - - return 0; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CStyleFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return (int)input; -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxFunctionalCastTestImpl() - { - var inputContents = @"int MyFunction(float input) -{ - return int(input); -} -"; - - var expectedOutputContents = @" - - - - - int - - float - - return (int)(input); - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxConstCastTestImpl() - { - var inputContents = @"void* MyFunction(const void* input) -{ - return const_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - void* - - void* - - return input; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxDynamicCastTestImpl() - { - var inputContents = @"struct MyStructA -{ - virtual void MyMethod() = 0; -}; - -struct MyStructB : MyStructA { }; - -MyStructB* MyFunction(MyStructA* input) -{ - return dynamic_cast(input); -} -"; - - var expectedOutputContents = $@" - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStructA*, void>)(lpVtbl[0]))((MyStructA*)Unsafe.AsPointer(ref this)); - - - - - - void** - - - void - - ((delegate* unmanaged[Thiscall]<MyStructB*, void>)(lpVtbl[0]))((MyStructB*)Unsafe.AsPointer(ref this)); - - - - - - MyStructB* - - MyStructA* - - return (MyStructB*)(input); - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxReinterpretCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return reinterpret_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CxxStaticCastTestImpl() - { - var inputContents = @"int* MyFunction(void* input) -{ - return static_cast(input); -} -"; - - var expectedOutputContents = @" - - - - - int* - - void* - - return (int*)(input); - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeclTestImpl() - { - var inputContents = @"\ -int MyFunction() -{ - int x = 0; - int y = 1, z = 2; - return x + y + z; -} -"; - - var expectedOutputContents = @" - - - - - int - int x = 0; - int y = 1, z = 2; - - return x + y + z; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - do - { - i++; - } - while (i < count); - - return i; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DoNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;;i--) - { - i += 2; - } - - for (x = 0;;x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - // x = 0; - // - // for (;; x--) - // { - // x += 2; - // } - - x = 0; - - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ForNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - for (int i = 0; i < count; i--) - i += 2; - - int x; - - for (x = 0; x < count; x--) - x += 2; - - x = 0; - - for (; x < count; x--) - x += 2; - - for (int i = 0;;i--) - i += 2; - - for (x = 0;;x--) - x += 2; - - for (int i = 0; i < count;) - i++; - - for (x = 0; x < count;) - x++; - - // x = 0; - // - // for (;; x--) - // x += 2; - - x = 0; - - for (; x < count;) - x++; - - for (int i = 0;;) - i++; - - for (x = 0;;) - x++; - - for (;;) - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - for (int i = 0; i < count; i--) - { - i += 2; - } - - int x; - - for (x = 0; x < count; x--) - { - x += 2; - } - - x = 0; - for (; x < count; x--) - { - x += 2; - } - - for (int i = 0;; i--) - { - i += 2; - } - - for (x = 0;; x--) - { - x += 2; - } - - for (int i = 0; i < count;) - { - i++; - } - - for (x = 0; x < count;) - { - x++; - } - - x = 0; - for (; x < count;) - { - x++; - } - - for (int i = 0;;) - { - i++; - } - - for (x = 0;;) - { - x++; - } - - for (;;) - { - return -1; - } - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - - return rhs; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - { - return lhs; - } - else - { - return rhs; - } -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseIfTestImpl() - { - var inputContents = @"int MyFunction(bool condition1, int a, int b, bool condition2, int c) -{ - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - - bool - - - int - - if (condition1) - { - return a; - } - else if (condition2) - { - return b; - } - - return c; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task IfElseNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(bool condition, int lhs, int rhs) -{ - if (condition) - return lhs; - else - return rhs; -} -"; - - var expectedOutputContents = @" - - - - - int - - bool - - - int - - - int - - if (condition) - { - return lhs; - } - else - { - return rhs; - } - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForArrayTestImpl() - { - var inputContents = @" -void MyFunction() -{ - int x[4] = { 1, 2, 3, 4 }; - int y[4] = { 1, 2, 3 }; - int z[] = { 1, 2 }; -} -"; - - var expectedOutputContents = @" - - - - - void - int[] x = new int[4] - { - 1, - 2, - 3, - 4, - }; - int[] y = new int[4] - { - 1, - 2, - 3, - default, - }; - int[] z = new int[2] - { - 1, - 2, - }; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InitListForRecordDeclTestImpl() - { - var inputContents = @"struct MyStruct -{ - float x; - float y; - float z; - float w; -}; - -MyStruct MyFunction1() -{ - return { 1.0f, 2.0f, 3.0f, 4.0f }; -} - -MyStruct MyFunction2() -{ - return { 1.0f, 2.0f, 3.0f }; -} -"; - - var expectedOutputContents = @" - - - - - float - - - float - - - float - - - float - - - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - w = 4.0f, - }; - - - MyStruct - return new MyStruct - { - x = 1.0f, - y = 2.0f, - z = 3.0f, - }; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MemberTestImpl() - { - var inputContents = @"struct MyStruct -{ - int value; -}; - -int MyFunction1(MyStruct instance) -{ - return instance.value; -} - -int MyFunction2(MyStruct* instance) -{ - return instance->value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - int - - MyStruct - - return instance.value; - - - int - - MyStruct* - - return instance->value; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RefToPtrTestImpl() - { - var inputContents = @"struct MyStruct { - int value; -}; - -bool MyFunction(const MyStruct& lhs, const MyStruct& rhs) -{ - return lhs.value == rhs.value; -} -"; - - var expectedOutputContents = @" - - - - - int - - - - - bool - - MyStruct* - - - MyStruct* - - return lhs->value == rhs->value; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXNullPtrTestImpl() - { - var inputContents = @"void* MyFunction() -{ - return nullptr; -} -"; - - var expectedOutputContents = @" - - - - - void* - return null; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnCXXBooleanLiteralTestImpl(string value) - { - var inputContents = $@"bool MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - bool - return {value}; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralDoubleTestImpl(string value) - { - var inputContents = $@"double MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - double - return {value}; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnFloatingLiteralSingleTestImpl(string value) - { - var inputContents = $@"float MyFunction() -{{ - return {value}; -}} -"; - - var expectedOutputContents = $@" - - - - - float - return {value}; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnEmptyTestImpl() - { - var inputContents = @"void MyFunction() -{ - return; -} -"; - - var expectedOutputContents = @" - - - - - void - return; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnIntegerLiteralInt32TestImpl() - { - var inputContents = @"int MyFunction() -{ - return -1; -} -"; - - var expectedOutputContents = @" - - - - - int - return -1; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task AccessUnionMemberTestImpl() - { - var inputContents = @"union MyUnion -{ - struct { int a; }; -}; - -void MyFunction() -{ - MyUnion myUnion; - myUnion.a = 10; -} -"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.a; - - - - - int - - - - - - void - MyUnion myUnion = new MyUnion(); - - myUnion.Anonymous.a = 10; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ReturnStructTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; -}; - -MyStruct MyFunction() -{ - MyStruct myStruct; - return myStruct; -} -"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - - - MyStruct - MyStruct myStruct = new MyStruct(); - - return myStruct; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - { - default: - { - return 0; - } - } -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SwitchNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int value) -{ - switch (value) - default: - { - return 0; - } - - switch (value) - default: - return 0; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - switch (value) - { - default: - { - return 0; - } - } - - switch (value) - { - default: - { - return 0; - } - } - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorAddrOfTestImpl() - { - var inputContents = @"int* MyFunction(int value) -{ - return &value; -} -"; - - var expectedOutputContents = @" - - - - - int* - - int - - return &value; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorDerefTestImpl() - { - var inputContents = @"int MyFunction(int* value) -{ - return *value; -} -"; - - var expectedOutputContents = @" - - - - - int - - int* - - return *value; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorLogicalNotTestImpl() - { - var inputContents = @"bool MyFunction(bool value) -{ - return !value; -} -"; - - var expectedOutputContents = @" - - - - - bool - - bool - - return !value; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPostfixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return value{opcode}; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return value{opcode}; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnaryOperatorPrefixTestImpl(string opcode) - { - var inputContents = $@"int MyFunction(int value) -{{ - return {opcode}value; -}} -"; - - var expectedOutputContents = $@" - - - - - int - - int - - return {opcode}value; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - { - i++; - } - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WhileNonCompoundTestImpl() - { - var inputContents = @"int MyFunction(int count) -{ - int i = 0; - - while (i < count) - i++; - - return i; -} -"; - - var expectedOutputContents = @" - - - - - int - - int - - int i = 0; - - while (i < count) - { - i++; - } - - return i; - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs deleted file mode 100644 index 6258e963..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionDeclarationDllImportTest.cs +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlPreviewWindows_FunctionDeclarationDllImportTest : FunctionDeclarationDllImportTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ArrayParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(const float color[4]);"; - - var expectedOutputContents = @" - - - - - void - - float* - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FunctionPointerParameterTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(void (*callback)());"; - - var expectedOutputContents = @" - - - - - void - - delegate* unmanaged[Cdecl]<void> - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NamespaceTestImpl() - { - var inputContents = @"namespace MyNamespace -{ - void MyFunction(); -}"; - - var entryPoint = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "__ZN11MyNamespace10MyFunctionEv" : "_ZN11MyNamespace10MyFunctionEv"; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - entryPoint = "?MyFunction@MyNamespace@@YAXXZ"; - } - - var expectedOutputContents = $@" - - - - - void - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TemplateParameterTestImpl(string nativeType, bool expectedNativeTypeAttr, string expectedManagedType, string expectedUsingStatement) - { - var inputContents = @$"template struct MyTemplate; - -extern ""C"" void MyFunction(MyTemplate<{nativeType}> myStruct);"; - - var expectedOutputContents = $@" - - - - - void - - MyTemplate<{expectedManagedType}> - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task TemplateMemberTestImpl() - { - var inputContents = @$"template struct MyTemplate -{{ -}}; - -struct MyStruct -{{ - MyTemplate a; -}}; -"; - - var expectedOutputContents = $@" - - - - - MyTemplate<IntPtr> - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: TemplateTestExcludedNames); - } - - protected override Task NoLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty); - } - - protected override Task WithLibraryPathTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["MyFunction"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task WithLibraryPathStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction();"; - - var expectedOutputContents = @" - - - - - void - - - - -"; - - var withLibraryPaths = new Dictionary - { - ["*"] = "ClangSharpPInvokeGenerator" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, libraryPath: string.Empty, withLibraryPaths: withLibraryPaths); - } - - protected override Task OptionalParameterTestImpl(string nativeType, string nativeInit, bool expectedNativeTypeNameAttr, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task OptionalParameterUnsafeTestImpl(string nativeType, string nativeInit, string expectedManagedType, string expectedManagedInit) - { - var inputContents = $@"extern ""C"" void MyFunction({nativeType} value = {nativeInit});"; - - var expectedOutputContents = $@" - - - - - void - - {expectedManagedType} - - {expectedManagedInit} - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithCallConvTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary { - ["MyFunction1"] = "Winapi" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithCallConvStarOverrideTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withCallConvs = new Dictionary - { - ["*"] = "Winapi", - ["MyFunction2"] = "StdCall" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withCallConvs: withCallConvs); - } - - protected override Task WithSetLastErrorTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "MyFunction1" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task WithSetLastErrorStarTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction1(int value); extern ""C"" void MyFunction2(int value);"; - - var expectedOutputContents = @" - - - - - void - - int - - - - void - - int - - - - - -"; - - var withSetLastErrors = new string[] - { - "*" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withSetLastErrors: withSetLastErrors); - } - - protected override Task SourceLocationTestImpl() - { - const string InputContents = @"extern ""C"" void MyFunction(float value);"; - - const string ExpectedOutputContents = @" - - - - - void - - float - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task VarargsTestImpl() => Task.CompletedTask; - - protected override Task IntrinsicsTestImpl() - { - const string InputContents = @"extern ""C"" void __builtin_cpu_init(); -#pragma intrinsic(__builtin_cpu_init)"; - - const string ExpectedOutputContents = @""; - - return ValidateGeneratedCSharpDefaultWindowsBindingsAsync(InputContents, ExpectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionPointerDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionPointerDeclarationTest.cs deleted file mode 100644 index 31ad3ded..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/FunctionPointerDeclarationTest.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlPreviewWindows_FunctionPointerDeclarationTest : FunctionPointerDeclarationTest -{ - protected override Task BasicTestImpl() - { - var inputContents = @"typedef void (*Callback)(); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task CallconvTestImpl() - { - var inputContents = @"typedef void (*Callback)() __attribute__((stdcall)); - -struct MyStruct { - Callback _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Stdcall]<void> - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerlessTypedefTestImpl() - { - var inputContents = @"typedef void (Callback)(); - -struct MyStruct { - Callback* _callback; -}; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs deleted file mode 100644 index 3bb5c851..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/StructDeclarationTest.cs +++ /dev/null @@ -1,1959 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlPreviewWindows_StructDeclarationTest : StructDeclarationTest -{ - protected override Task IncompleteArraySizeTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} x[]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - return ref Unsafe.Add(ref e0, index); - - - - Span<{expectedManagedType}> - - int - - MemoryMarshal.CreateSpan(ref e0, length); - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyStruct; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - - byte - - return (byte)(_bitfield3 & 0x1u); - - - - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - - - - int - - - int - - return (_bitfield4 << 31) >> 31; - - - - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - - - - int - - return (_bitfield4 << 30) >> 31; - - - - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldWithNativeBitfieldAttributeTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -struct MyStruct2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -struct MyStruct3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedOutputContents = @" - - - - - NativeBitfield(""o0_b0_24"", offset: 0, length: 24) - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - NativeBitfield(""o4_b0_16"", offset: 0, length: 16) - NativeBitfield(""o4_b16_3"", offset: 16, length: 3) - NativeBitfield(""o4_b19_3"", offset: 19, length: 3) - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - NativeBitfield(""o8_b0_1"", offset: 0, length: 1) - byte - - - byte - - return (byte)(_bitfield3 & 0x1u); - - - - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - - - - NativeBitfield(""o12_b0_1"", offset: 0, length: 1) - NativeBitfield(""o12_b1_1"", offset: 1, length: 1) - int - - - int - - return (_bitfield4 << 31) >> 31; - - - - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - - - - int - - return (_bitfield4 << 30) >> 31; - - - - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - NativeBitfield(""o8_b0_1"", offset: 0, length: 1) - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - NativeBitfield(""o0_b0_1"", offset: 0, length: 1) - NativeBitfield(""o0_b1_1"", offset: 1, length: 1) - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeBitfieldAttribute); - } - - protected override Task DeclTypeTestImpl() - { - var inputContents = @"extern ""C"" void MyFunction(); - -typedef struct -{ - decltype(&MyFunction) _callback; -} MyStruct; -"; - - var expectedOutputContents = @" - - - - - delegate* unmanaged[Cdecl]<void> - - - - - void - - - - -"; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(2 * 1 * 3 * 4) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -typedef MyStruct MyBuffer[3]; - -struct MyOtherStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} value; -}}; - -struct MyOtherStruct -{{ - MyStruct c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyStruct - - - InlineArray(3) - - MyStruct - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(2 * 1 * 3 * 4) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -struct MyStruct -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -struct __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyStruct1 -{{ - int x; -}}; - -struct DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyStruct2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task InheritanceTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task InheritanceWithNativeInheritanceAttributeTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - int x; - int y; -}; - -struct MyStruct1B -{ - int x; - int y; -}; - -struct MyStruct2 : MyStruct1A, MyStruct1B -{ - int z; - int w; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - MyStruct1A - - - MyStruct1B - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateNativeInheritanceAttribute); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef union {{ - {nativeType} value; -}} MyUnion; - -struct MyStruct -{{ - {nativeType} x; - {nativeType} y; - - struct - {{ - {nativeType} z; - - struct - {{ - {nativeType} value; - }} w; - - MyUnion u; - {nativeType} buffer1[4]; - MyUnion buffer2[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Struct - - - ref {expectedManagedType} - - return ref Anonymous.z; - - - - ref _Anonymous_e__Struct._w_e__Struct - - return ref Anonymous.w; - - - - ref MyUnion - - return ref Anonymous.u; - - - - Span<{expectedManagedType}> - - return Anonymous.buffer1; - - - - Span<MyUnion> - - return Anonymous.buffer2; - - - - - {expectedManagedType} - - - _w_e__Struct - - - MyUnion - - - {expectedManagedType} - - - MyUnion - - - - {expectedManagedType} - - - - InlineArray(4) - - {expectedManagedType} - - - - InlineArray(4) - - MyUnion - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"struct MyStruct -{ - int x; - int y; - - struct - { - int z; - - struct - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.z; - - - - ref int - - return ref Anonymous.Anonymous1.w; - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Struct - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - struct MyNestedStruct - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"struct MyStruct -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef struct MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task PackTestImpl() - { - const string InputContents = @"struct MyStruct1 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; - -#pragma pack(4) - -struct MyStruct2 { - unsigned Field1; - - void* Field2; - - unsigned Field3; -}; -"; - - var packing = Environment.Is64BitProcess ? " layout=\"Sequential\" pack=\"4\"" : string.Empty; - - var expectedOutputContents = $@" - - - - - uint - - - void* - - - uint - - - - - uint - - - void* - - - uint - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(InputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"struct example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef struct example_s example_t; - -struct example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef struct _MyStruct MyStruct;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyStruct"] = "MyStruct" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"struct MyStruct -{ - double r; - double g; - double b; - - struct - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Struct - - - ref double - - return ref Anonymous.a; - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Struct" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef struct MyStruct* MyStructPtr; -typedef struct MyStruct& MyStructRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef struct MyStruct MyStruct; - -struct MyStruct -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -struct MyStruct -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UsingDeclarationTestImpl() - { - var inputContents = @"struct MyStruct1A -{ - void MyMethod() { } -}; - -struct MyStruct1B : MyStruct1A -{ - using MyStruct1A::MyMethod; -}; -"; - - var expectedOutputContents = @" - - - - - void - - - - - - void - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WithAccessSpecifierTestImpl() - { - var inputContents = @"struct MyStruct1 -{ - int Field1; - int Field2; -}; - -struct MyStruct2 -{ - int Field1; - int Field2; -}; - -struct MyStruct3 -{ - int Field1; - int Field2; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - - - int - - - int - - - - - int - - - int - - - - -"; - - var withAccessSpecifiers = new Dictionary { - ["MyStruct1"] = AccessSpecifier.Private, - ["MyStruct2"] = AccessSpecifier.Internal, - ["Field1"] = AccessSpecifier.Private, - ["MyStruct3.Field2"] = AccessSpecifier.Internal, - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, withAccessSpecifiers: withAccessSpecifiers); - } - - protected override Task WithPackingTestImpl() - { - const string InputContents = @"struct MyStruct -{ - size_t FixedBuffer[2]; -}; -"; - - const string ExpectedOutputContents = @" - - - - - nuint - - - InlineArray(2) - - nuint - - - - - -"; - - var withPackings = new Dictionary { - ["MyStruct"] = "CustomPackValue" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents, withPackings: withPackings); - } - - protected override Task SourceLocationAttributeTestImpl() - { - const string InputContents = @"struct MyStruct -{ - int r; - int g; - int b; -}; -"; - - const string ExpectedOutputContents = @" - - - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(InputContents, ExpectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateSourceLocationAttribute); - } - - protected override Task AnonStructAndAnonStructArrayImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { int First; }; - struct { int Second; } MyArray[2]; -} MyStruct;"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - _MyArray_e__Struct - - - ref int - - return ref Anonymous.First; - - - - - int - - - - - int - - - - InlineArray(2) - - _MyArray_e__Struct - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task DeeplyNestedAnonStructsImpl() - { - var inputContents = @"typedef struct _MyStruct -{ - struct { struct { - struct { int Value1; }; - struct { int Value2; }; - }; }; -} MyStruct;"; - - var expectedOutputContents = @" - - - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.Anonymous1.Anonymous2.Value1; - - - - ref int - - return ref Anonymous.Anonymous1.Anonymous3.Value2; - - - - - _Anonymous1_e__Struct - - - - _Anonymous2_e__Struct - - - _Anonymous3_e__Struct - - - - int - - - - - int - - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs deleted file mode 100644 index e24fadc9..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/UnionDeclarationTest.cs +++ /dev/null @@ -1,1317 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlPreviewWindows_UnionDeclarationTest : UnionDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicTestInCModeImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}} MyUnion; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: []); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BitfieldTestImpl() - { - var inputContents = @"union MyUnion1 -{ - unsigned int o0_b0_24 : 24; - unsigned int o4_b0_16 : 16; - unsigned int o4_b16_3 : 3; - int o4_b19_3 : 3; - unsigned char o8_b0_1 : 1; - int o12_b0_1 : 1; - int o12_b1_1 : 1; -}; - -union MyUnion2 -{ - unsigned int o0_b0_1 : 1; - int x; - unsigned int o8_b0_1 : 1; -}; - -union MyUnion3 -{ - unsigned int o0_b0_1 : 1; - unsigned int o0_b1_1 : 1; -}; -"; - - var expectedPack = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @" pack=""1""" : ""; - - var expectedOutputContents = $@" - - - - - uint - - - uint - - return _bitfield1 & 0xFFFFFFu; - - - - _bitfield1 = (_bitfield1 & ~0xFFFFFFu) | (value & 0xFFFFFFu); - - - - uint - - - uint - - return _bitfield2 & 0xFFFFu; - - - - _bitfield2 = (_bitfield2 & ~0xFFFFu) | (value & 0xFFFFu); - - - - uint - - return (_bitfield2 >> 16) & 0x7u; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 16)) | ((value & 0x7u) << 16); - - - - int - - return (int)(_bitfield2 << 10) >> 29; - - - - _bitfield2 = (_bitfield2 & ~(0x7u << 19)) | (uint)((value & 0x7) << 19); - - - - byte - - - byte - - return (byte)(_bitfield3 & 0x1u); - - - - _bitfield3 = (byte)((_bitfield3 & ~0x1u) | (value & 0x1u)); - - - - int - - - int - - return (_bitfield4 << 31) >> 31; - - - - _bitfield4 = (_bitfield4 & ~0x1) | (value & 0x1); - - - - int - - return (_bitfield4 << 30) >> 31; - - - - _bitfield4 = (_bitfield4 & ~(0x1 << 1)) | ((value & 0x1) << 1); - - - - - - uint - - - uint - - return _bitfield1 & 0x1u; - - - - _bitfield1 = (_bitfield1 & ~0x1u) | (value & 0x1u); - - - - int - - - uint - - - uint - - return _bitfield2 & 0x1u; - - - - _bitfield2 = (_bitfield2 & ~0x1u) | (value & 0x1u); - - - - - - uint - - - uint - - return _bitfield & 0x1u; - - - - _bitfield = (_bitfield & ~0x1u) | (value & 0x1u); - - - - uint - - return (_bitfield >> 1) & 0x1u; - - - - _bitfield = (_bitfield & ~(0x1u << 1)) | ((value & 0x1u) << 1); - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ExcludeTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - var expectedOutputContents = string.Empty; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: ExcludeTestExcludedNames); - } - - protected override Task FixedSizedBufferNonPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(2 * 1 * 3 * 4) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -typedef MyUnion MyBuffer[3]; - -union MyOtherUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferNonPrimitiveWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} value; -}}; - -union MyOtherUnion -{{ - MyUnion c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - MyUnion - - - InlineArray(3) - - MyUnion - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPointerTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - ref {expectedManagedType} - - int - - - fixed ({expectedManagedType}* pThis = &e0) - {{ - return ref pThis[index]; - }} - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[3]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveMultidimensionalTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} c[2][1][3][4]; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(2 * 1 * 3 * 4) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task FixedSizedBufferPrimitiveTypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyBuffer[3]; - -union MyUnion -{{ - MyBuffer c; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - InlineArray(3) - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - protected override Task GuidTestImpl() - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Non-Windows doesn't support __declspec(uuid("")) - return Task.CompletedTask; - } - - var inputContents = $@"#define DECLSPEC_UUID(x) __declspec(uuid(x)) - -union __declspec(uuid(""00000000-0000-0000-C000-000000000046"")) MyUnion1 -{{ - int x; -}}; - -union DECLSPEC_UUID(""00000000-0000-0000-C000-000000000047"") MyUnion2 -{{ - int x; -}}; -"; - - var expectedOutputContents = $@" - - - - - int - - - - - int - - - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidTestExcludedNames); - } - - protected override Task NestedAnonymousTestImpl(string nativeType, string expectedManagedType, int line, int column) - { - var inputContents = $@"typedef struct {{ - {nativeType} value; -}} MyStruct; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union - {{ - {nativeType} a; - - MyStruct s; - - {nativeType} buffer[4]; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - _Anonymous_e__Union - - - ref {expectedManagedType} - - return ref Anonymous.a; - - - - ref MyStruct - - return ref Anonymous.s; - - - - Span<{expectedManagedType}> - - return Anonymous.buffer; - - - - - {expectedManagedType} - - - MyStruct - - - {expectedManagedType} - - - InlineArray(4) - - {expectedManagedType} - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedAnonymousWithBitfieldTestImpl() - { - var inputContents = @"union MyUnion -{ - int x; - int y; - - union - { - int z; - - union - { - int w; - int o0_b0_16 : 16; - int o0_b16_4 : 4; - }; - }; -}; -"; - - var expectedOutputContents = @" - - - - - int - - - int - - - _Anonymous_e__Union - - - ref int - - return ref Anonymous.z; - - - - ref int - - return ref Anonymous.Anonymous1.w; - - - - int - - return Anonymous.Anonymous1.o0_b0_16; - - - Anonymous.Anonymous1.o0_b0_16 = value; - - - - int - - return Anonymous.Anonymous1.o0_b16_4; - - - Anonymous.Anonymous1.o0_b16_4 = value; - - - - - int - - - _Anonymous1_e__Union - - - - int - - - int - - - int - - return (_bitfield << 16) >> 16; - - - - _bitfield = (_bitfield & ~0xFFFF) | (value & 0xFFFF); - - - - int - - return (_bitfield << 12) >> 28; - - - - _bitfield = (_bitfield & ~(0xF << 16)) | ((value & 0xF) << 16); - - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - - protected override Task NestedTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NestedWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - - union MyNestedUnion - {{ - {nativeType} r; - {nativeType} g; - {nativeType} b; - {nativeType} a; - }}; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NewKeywordTestImpl() - { - var inputContents = @"union MyUnion -{ - int Equals; - int Dispose; - int GetHashCode; - int GetType; - int MemberwiseClone; - int ReferenceEquals; - int ToString; -};"; - - var expectedOutputContents = $@" - - - - - int - - - int - - - int - - - int - - - int - - - int - - - int - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoDefinitionTestImpl() - { - var inputContents = "typedef union MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfTestImpl() - { - var inputContents = @"union example_s { - example_s* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task PointerToSelfViaTypedefTestImpl() - { - var inputContents = @"typedef union example_s example_t; - -union example_s { - example_t* next; - void* data; -};"; - - var expectedOutputContents = $@" - - - - - example_s* - - - void* - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task RemapTestImpl() - { - var inputContents = "typedef union _MyUnion MyUnion;"; - - var expectedOutputContents = $@" - - - - - -"; - - var remappedNames = new Dictionary { ["_MyUnion"] = "MyUnion" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task RemapNestedAnonymousTestImpl() - { - var inputContents = @"union MyUnion -{ - double r; - double g; - double b; - - union - { - double a; - }; -};"; - - var expectedOutputContents = @" - - - - - double - - - double - - - double - - - _Anonymous_e__Union - - - ref double - - return ref Anonymous.a; - - - - - double - - - - - -"; - - var remappedNames = new Dictionary { - ["__AnonymousField_ClangUnsavedFile_L7_C5"] = "Anonymous", - ["__AnonymousRecord_ClangUnsavedFile_L7_C5"] = "_Anonymous_e__Union" - }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); - } - - protected override Task SkipNonDefinitionTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionPointerTestImpl() - { - var inputContents = @"typedef union MyUnion* MyUnionPtr; -typedef union MyUnion& MyUnionRef; -"; - - var expectedOutputContents = @" - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task SkipNonDefinitionWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef union MyUnion MyUnion; - -union MyUnion -{{ - {nativeType} r; - {nativeType} g; - {nativeType} b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task TypedefTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"typedef {nativeType} MyTypedefAlias; - -union MyUnion -{{ - MyTypedefAlias r; - MyTypedefAlias g; - MyTypedefAlias b; -}}; -"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - - {expectedManagedType} - - - {expectedManagedType} - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UnionWithAnonStructWithAnonUnionImpl() - { - var inputContents = $@"typedef union _MY_UNION -{{ - long AsArray[2]; - struct - {{ - long First; - union - {{ - struct - {{ - long Second; - }} A; - - struct - {{ - long Second; - }} B; - }}; - }}; -}} MY_UNION;"; - - var expectedOutputContents = $@" - - - - - int - - - _Anonymous_e__Struct - - - ref int - - return ref Anonymous.First; - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._A_e__Struct - - return ref Anonymous.Anonymous.A; - - - - ref _Anonymous_e__Struct._Anonymous_e__Union._B_e__Struct - - return ref Anonymous.Anonymous.B; - - - - - int - - - _Anonymous_e__Union - - - - _A_e__Struct - - - _B_e__Struct - - - - int - - - - - int - - - - - - InlineArray(2) - - int - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } -} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs deleted file mode 100644 index 1c8c3fb6..00000000 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/XmlPreviewWindows/VarDeclarationTest.cs +++ /dev/null @@ -1,543 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. - -using System.Collections.Generic; -using System.Threading.Tasks; -using NUnit.Framework; - -namespace ClangSharp.UnitTests; - -[Platform("win")] -public sealed class XmlPreviewWindows_VarDeclarationTest : VarDeclarationTest -{ - protected override Task BasicTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task BasicWithNativeTypeNameTestImpl(string nativeType, string expectedManagedType) - { - var inputContents = $@"{nativeType} MyVariable = 0;"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - 0 - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task GuidMacroTestImpl() - { - var inputContents = $@"struct GUID {{ - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[8]; -}}; - -const GUID IID_IUnknown = {{ 0x00000000, 0x0000, 0x0000, {{ 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 }} }}; -"; - - var expectedOutputContents = $@" - - - - - Guid - - new Guid(0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46) - - - - - -"; - - var remappedNames = new Dictionary { ["GUID"] = "Guid" }; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: GuidMacroTestExcludedNames, remappedNames: remappedNames); - } - - protected override Task MacroTestImpl(string nativeValue, string expectedManagedType, string expectedManagedValue) - { - var inputContents = $@"#define MyMacro1 {nativeValue} -#define MyMacro2 MyMacro1"; - - var expectedOutputContents = $@" - - - - - {expectedManagedType} - - {expectedManagedValue} - - - - {expectedManagedType} - - {expectedManagedValue} - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultilineMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 0 + \ -1"; - - var expectedOutputContents = $@" - - - - - int - - 0 + 1 - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task NoInitializerTestImpl(string nativeType) - { - var inputContents = $@"{nativeType} MyVariable;"; - var expectedOutputContents = ""; - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf8StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 ""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task Utf16StringLiteralMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 u""Test\0\\\r\n\t\"""""; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralConstTestImpl() - { - var inputContents = $@"const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralConstTestImpl() - { - var inputContents = $@"const char MyConst1[] = ""Test\0\\\r\n\t\""""; -const char* MyConst2 = ""Test\0\\\r\n\t\""""; -const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - byte[] - - ""Test\0\\\r\n\t\""""u8.ToArray() - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task WideStringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const wchar_t MyConst1[] = L""Test\0\\\r\n\t\""""; -static const wchar_t* MyConst2 = L""Test\0\\\r\n\t\""""; -static const wchar_t* const MyConst3 = L""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - string - - ""Test\0\\\r\n\t\"""" - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task StringLiteralStaticConstTestImpl() - { - var inputContents = $@"static const char MyConst1[] = ""Test\0\\\r\n\t\""""; -static const char* MyConst2 = ""Test\0\\\r\n\t\""""; -static const char* const MyConst3 = ""Test\0\\\r\n\t\"""";"; - - var expectedOutputContents = $@" - - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - byte[] - - ""Test\0\\\r\n\t\""""u8.ToArray() - - - - ReadOnlySpan<byte> - - ""Test\0\\\r\n\t\""""u8 - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 (long)0x80000000L -#define MyMacro2 (int)0x80000000"; - - var expectedOutputContents = $@" - - - - - int - - - - (int)(0x80000000) - - - - - - int - - - - (int)(0x80000000) - - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedFunctionLikeCastMacroTestImpl() - { - var inputContents = $@"#define MyMacro1 unsigned(-1)"; - - var expectedOutputContents = $@" - - - - - uint - - - - (uint)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedConversionMacroTest2Impl() - { - var inputContents = $@"#define MyMacro1(x, y, z) ((int)(((unsigned long)(x)<<31) | ((unsigned long)(y)<<16) | ((unsigned long)(z)))) -#define MyMacro2(n) MyMacro1(1, 2, n) -#define MyMacro3 MyMacro2(3)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(((uint)(1) << 31) | ((uint)(2) << 16) | ((uint)(3)))) - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, excludedNames: UncheckedConversionMacroTest2ExcludedNames); - } - - protected override Task UncheckedPointerMacroTestImpl() - { - var inputContents = $@"#define Macro1 ((int*) -1)"; - - var expectedOutputContents = $@" - - - - - int* - - - ((int*)(-1)) - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task UncheckedReinterpretCastMacroTestImpl() - { - var inputContents = $@"#define Macro1 reinterpret_cast(-1)"; - - var expectedOutputContents = $@" - - - - - int* - - - - (int*)(-1) - - - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task MultidimensionlArrayTestImpl() - { - var inputContents = $@"const int MyArray[2][2] = {{ {{ 0, 1 }}, {{ 2, 3 }} }};"; - - var expectedOutputContents = $@" - - - - - int[][] - - new int[2][] - {{ - new int[2] - {{ - 0, - 1, - }}, - new int[2] - {{ - 2, - 3, - }}, - }} - - - - - -"; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents); - } - - protected override Task ConditionalDefineConstTestImpl() - { - var inputContents = @"typedef int TESTRESULT; -#define TESTRESULT_FROM_WIN32(x) ((TESTRESULT)(x) <= 0 ? ((TESTRESULT)(x)) : ((TESTRESULT) (((x) & 0x0000FFFF) | (7 << 16) | 0x80000000))) -#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = $@" - - - - - int - - - ((int)(10048) <= 0 ? ((int)(10048)) : ((int)(((10048) & 0x0000FFFF) | (7 << 16) | 0x80000000))) - - - - - - -"; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: 'TESTRESULT_FROM_WIN32'. Generated bindings may be incomplete.", "Line 2, Column 9 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } - - protected override Task UndefinedFunctionLikeMacroTestImpl() - { - var inputContents = @"#define ADDRESS_IN_USE TESTRESULT_FROM_WIN32(10048)"; - - var expectedOutputContents = ""; - var diagnostics = new Diagnostic[] { new Diagnostic(DiagnosticLevel.Warning, "Macro definition 'ADDRESS_IN_USE' could not be resolved to a supported expression. Generated bindings may be incomplete.", "Line 2, Column 12 in ClangUnsavedFile.h") }; - - return ValidateGeneratedXmlPreviewWindowsBindingsAsync(inputContents, expectedOutputContents, expectedDiagnostics: diagnostics); - } -} From 00c46f3e11676d48dd8b474a2c04e05465f5c7a3 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Mon, 13 Jul 2026 12:43:45 -0700 Subject: [PATCH 3/3] Migrate the standalone generator fixtures to the baseline harness Move the root-level single-config fixtures -- the second, lighter test style that never used the 16-way matrix -- onto the same checked-in baseline model, so the suite has one consistent shape. Each fixture now derives from StandaloneBaselineTest, supplies only its input and options, and names the single variant it exercises; the expected output lives in a baseline file extracted byte-for-byte from the old inline string. Host-sensitive cases whose expected output branched on the runtime OS are keyed by host so each side is asserted on its own platform. CTest.IntptrDefineTest is intentionally left inline: it branches both the input and the config on the host OS, which the single-variant helpers do not model, so it keeps using the legacy ValidateGenerated* wrappers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- ...ousEnumReferenceExcludeUsingStaticsTest.cs | 21 +- ...dWithBackingClass.CSharp.Latest.Windows.cs | 12 + ...ompatibleTest.CSharp.Compatible.Windows.cs | 51 ++ .../LatestTest.CSharp.Latest.Windows.cs | 51 ++ .../C/BasicTest.CSharp.Latest.Unix.cs | 16 + .../C/BasicTest.CSharp.Latest.Windows.cs | 15 + ...yBackingTypeTestUnix.CSharp.Latest.Unix.cs | 96 +++ ...lBackingTypeTestUnix.CSharp.Latest.Unix.cs | 53 ++ ...ertyTypeCastTestUnix.CSharp.Latest.Unix.cs | 41 + ...peCastTestWindows.CSharp.Latest.Windows.cs | 40 + ...eDefPropertyTypeCast.CSharp.Latest.Unix.cs | 41 + ...astWithRemappingTest.CSharp.Latest.Unix.cs | 41 + ...ithSelfRemappingTest.CSharp.Latest.Unix.cs | 35 + ...eDefTypeCastTestUnix.CSharp.Latest.Unix.cs | 21 + ...esRegressionTestUnix.CSharp.Latest.Unix.cs | 23 + ...CLongDefinesTestUnix.CSharp.Latest.Unix.cs | 32 + ...efinesTestWindows.CSharp.Latest.Windows.cs | 17 + .../C/EnumTest.CSharp.Latest.Unix.cs | 19 + .../C/EnumTest.CSharp.Latest.Windows.cs | 19 + .../C/MacroTest.CSharp.Latest.Windows.cs | 11 + .../C/StructTest.CSharp.Latest.Windows.cs | 45 + .../C/UnionTest.CSharp.Latest.Windows.cs | 23 + ...edIntBitshiftTest.CSharp.Latest.Windows.cs | 89 ++ ...dIntBitshiftTestUnix.CSharp.Latest.Unix.cs | 11 + ...terArithmeticTest.CSharp.Latest.Windows.cs | 10 + ...lsAreConcatenated.CSharp.Latest.Windows.cs | 12 + ...reNotOverIndented.CSharp.Latest.Windows.cs | 22 + ...asNoTrailingBrace.CSharp.Latest.Windows.cs | 9 + ...asNoTrailingBrace.CSharp.Latest.Windows.cs | 8 + ...rWhenDisabled.CSharp.Compatible.Windows.cs | 31 + ...dsWhenEnabled.CSharp.Compatible.Windows.cs | 64 ++ ...dStaysIntPtrUnix.CSharp.Compatible.Unix.cs | 14 + ...IntPtrWindows.CSharp.Compatible.Windows.cs | 14 + ...onConstGlobalTest.CSharp.Latest.Windows.cs | 18 + ...dAfterMethodClass.CSharp.Latest.Windows.cs | 57 ++ ...odClassFileScoped.CSharp.Latest.Windows.cs | 56 ++ ...leScopedNamespace.CSharp.Latest.Windows.cs | 49 ++ ...InSharedNamespace.CSharp.Latest.Windows.cs | 50 ++ ...eThroughSubobject.CSharp.Latest.Windows.cs | 42 + ...ryBaseAsSubobject.CSharp.Latest.Windows.cs | 34 + ...ryBaseAsSubobject.CSharp.Latest.Windows.cs | 37 + ...WithExplicitVtbls.CSharp.Latest.Windows.cs | 55 ++ ...ltipleInheritance.CSharp.Latest.Windows.cs | 68 ++ ...rkerInterfaceOnly.CSharp.Latest.Windows.cs | 81 ++ ...edTypeIsQualified.CSharp.Latest.Windows.cs | 17 + .../NullPtrMacroTest.CSharp.Latest.Windows.cs | 8 + .../WithAttributes.CSharp.Latest.Windows.cs | 22 + .../WithUsings.CSharp.Latest.Windows.cs | 24 + ...sCppAttributeList.CSharp.Latest.Windows.cs | 11 + ...rencesAreStripped.CSharp.Latest.Windows.cs | 11 + ...eratesValidHelper.CSharp.Latest.Windows.cs | 137 +++ ...shingTypeAndWarns.CSharp.Latest.Windows.cs | 22 + ...ClashingFieldName.CSharp.Latest.Windows.cs | 22 + ...sClashingTypeName.CSharp.Latest.Windows.cs | 22 + ...dMarksClassUnsafe.CSharp.Latest.Windows.cs | 14 + ...verridesFieldType.CSharp.Latest.Windows.cs | 10 + .../BooleanBitfieldTest.cs | 115 +-- .../CTest.cs | 793 +----------------- .../DeprecatedAdjacentStringTest.cs | 21 +- .../FileScopedNamespaceTest.cs | 56 +- .../FixedBufferIndexerOverloadsTest.cs | 108 +-- .../FunctionPointerRemapTest.cs | 25 +- .../GlobalStructInitializerTest.cs | 27 +- .../HelperTypesTest.cs | 233 +---- .../MultipleBaseVtblSubobjectTest.cs | 346 +------- .../NestedTypeReferenceTest.cs | 26 +- .../NullPtrMacroBindingTest.cs | 17 +- .../OptionsTest.cs | 58 +- .../SalFieldAttributeTest.cs | 20 +- .../StripEnumMemberReferenceTest.cs | 20 +- .../TransparentStructTest.cs | 146 +--- .../UnionFieldTypeNameClashTest.cs | 83 +- .../UnsafeFixedSizeBufferTest.cs | 23 +- .../WithTypeFieldTest.cs | 19 +- 74 files changed, 1982 insertions(+), 2028 deletions(-) create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/AnonymousEnumReferenceExcludeUsingStatics/ReferenceIsQualifiedWithBackingClass.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/BooleanBitfield/CompatibleTest.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/BooleanBitfield/LatestTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BasicTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BasicTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertyBackingTypeTestUnix.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertySmallBackingTypeTestUnix.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertyTypeCastTestUnix.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertyTypeCastTestWindows.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumTypeDefPropertyTypeCast.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumTypeDefPropertyTypeCastWithRemappingTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumTypeDefPropertyTypeCastWithSelfRemappingTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldTypeDefTypeCastTestUnix.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/CLongDefinesRegressionTestUnix.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/CLongDefinesTestUnix.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/CLongDefinesTestWindows.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/EnumTest.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/EnumTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/MacroTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/StructTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/UnionTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/UnsignedIntBitshiftTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/UnsignedIntBitshiftTestUnix.CSharp.Latest.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/VoidPointerArithmeticTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedAdjacentString/AdjacentStringLiteralsAreConcatenated.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FileScopedNamespace/MembersAfterFirstAreNotOverIndented.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FileScopedNamespace/MethodClassHasNoTrailingBrace.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FileScopedNamespace/StructHasNoTrailingBrace.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FixedBufferIndexerOverloads/GeneratesOnlyIntIndexerWhenDisabled.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FixedBufferIndexerOverloads/GeneratesOverloadsWhenEnabled.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerRemap/RemappedFnptrTypedefFieldStaysIntPtrUnix.CSharp.Compatible.Unix.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerRemap/RemappedFnptrTypedefFieldStaysIntPtrWindows.CSharp.Compatible.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/GlobalStructInitializer/NonConstGlobalTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedAfterMethodClass.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedAfterMethodClassFileScoped.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedInSharedFileScopedNamespace.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedInSharedNamespace.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/DispatchesNonPrimaryBaseThroughSubobject.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/EmitsFieldBearingPrimaryBaseAsSubobject.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/EmitsSecondaryBaseAsSubobject.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/EmitsSecondaryBaseAsSubobjectWithExplicitVtbls.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/FallsBackToFlattenedVtblForNestedMultipleInheritance.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/InheritsPrimaryBaseMarkerInterfaceOnly.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/NestedTypeReference/NestedTypeIsQualified.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/NullPtrMacroBinding/NullPtrMacroTest.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/Options/WithAttributes.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/Options/WithUsings.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/SalFieldAttribute/FieldSalAnnotationGeneratesCppAttributeList.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StripEnumMemberReference/SiblingReferencesAreStripped.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/TransparentStruct/BooleanKindGeneratesValidHelper.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionFieldTypeNameClash/AutoRenamesClashingTypeAndWarns.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionFieldTypeNameClash/RemapFieldControlsClashingFieldName.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionFieldTypeNameClash/RemapTypeControlsClashingTypeName.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnsafeFixedSizeBuffer/RemappedFixedSizeBufferLowersToPointerAndMarksClassUnsafe.CSharp.Latest.Windows.cs create mode 100644 tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/WithTypeField/OverridesFieldType.CSharp.Latest.Windows.cs diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/AnonymousEnumReferenceExcludeUsingStaticsTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/AnonymousEnumReferenceExcludeUsingStaticsTest.cs index 31c8fc23..c3dc93ab 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/AnonymousEnumReferenceExcludeUsingStaticsTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/AnonymousEnumReferenceExcludeUsingStaticsTest.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; @@ -12,8 +13,10 @@ namespace ClangSharp.UnitTests; /// rather than the non-existent __AnonymousEnum_* enum name. /// [Platform("win")] -public sealed class AnonymousEnumReferenceExcludeUsingStaticsTest : PInvokeGeneratorTest +public sealed class AnonymousEnumReferenceExcludeUsingStaticsTest : StandaloneBaselineTest { + protected override string Area => "AnonymousEnumReferenceExcludeUsingStatics"; + [Test] public Task ReferenceIsQualifiedWithBackingClass() { @@ -26,23 +29,9 @@ enum MyEnum2 : int { MyEnum2_Value1 = MyEnum1_Value1, }; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum2 - { - MyEnum2_Value1 = Methods.MyEnum1_Value1, - } - - public static partial class Methods - { - public const int MyEnum1_Value1 = 1; - } -} "; var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.DontUseUsingStaticsForEnums, expectedDiagnostics: diagnostics); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, PInvokeGeneratorConfigurationOptions.DontUseUsingStaticsForEnums, expectedDiagnostics: diagnostics); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/AnonymousEnumReferenceExcludeUsingStatics/ReferenceIsQualifiedWithBackingClass.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/AnonymousEnumReferenceExcludeUsingStatics/ReferenceIsQualifiedWithBackingClass.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..8748e8e0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/AnonymousEnumReferenceExcludeUsingStatics/ReferenceIsQualifiedWithBackingClass.CSharp.Latest.Windows.cs @@ -0,0 +1,12 @@ +namespace ClangSharp.Test +{ + public enum MyEnum2 + { + MyEnum2_Value1 = Methods.MyEnum1_Value1, + } + + public static partial class Methods + { + public const int MyEnum1_Value1 = 1; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/BooleanBitfield/CompatibleTest.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/BooleanBitfield/CompatibleTest.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..2807ee1c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/BooleanBitfield/CompatibleTest.CSharp.Compatible.Windows.cs @@ -0,0 +1,51 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public byte _bitfield1; + + [NativeTypeName("bool : 1")] + public bool a + { + get + { + return (_bitfield1 & 0x1u) != 0; + } + + set + { + _bitfield1 = (byte)((_bitfield1 & ~0x1u) | ((value ? 1 : 0) & 0x1u)); + } + } + + [NativeTypeName("bool : 1")] + public bool b + { + get + { + return ((_bitfield1 >> 1) & 0x1u) != 0; + } + + set + { + _bitfield1 = (byte)((_bitfield1 & ~(0x1u << 1)) | (((value ? 1 : 0) & 0x1u) << 1)); + } + } + + public int _bitfield2; + + [NativeTypeName("int : 2")] + public int c + { + get + { + return (_bitfield2 << 30) >> 30; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x3) | (value & 0x3); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/BooleanBitfield/LatestTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/BooleanBitfield/LatestTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..3b6f7cd7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/BooleanBitfield/LatestTest.CSharp.Latest.Windows.cs @@ -0,0 +1,51 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public byte _bitfield1; + + [NativeTypeName("bool : 1")] + public bool a + { + readonly get + { + return (_bitfield1 & 0x1u) != 0; + } + + set + { + _bitfield1 = (byte)((_bitfield1 & ~0x1u) | ((value ? 1 : 0) & 0x1u)); + } + } + + [NativeTypeName("bool : 1")] + public bool b + { + readonly get + { + return ((_bitfield1 >> 1) & 0x1u) != 0; + } + + set + { + _bitfield1 = (byte)((_bitfield1 & ~(0x1u << 1)) | (((value ? 1 : 0) & 0x1u) << 1)); + } + } + + public int _bitfield2; + + [NativeTypeName("int : 2")] + public int c + { + readonly get + { + return (_bitfield2 << 30) >> 30; + } + + set + { + _bitfield2 = (_bitfield2 & ~0x3) | (value & 0x3); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BasicTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BasicTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..9360543f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BasicTest.CSharp.Latest.Unix.cs @@ -0,0 +1,16 @@ +namespace ClangSharp.Test +{ + [NativeTypeName("unsigned int")] + public enum MyEnum : uint + { + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, + } + + public partial struct MyStruct + { + [NativeTypeName("enum_t")] + public MyEnum _field; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BasicTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BasicTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..95603a8e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BasicTest.CSharp.Latest.Windows.cs @@ -0,0 +1,15 @@ +namespace ClangSharp.Test +{ + public enum MyEnum + { + MyEnum_Value0, + MyEnum_Value1, + MyEnum_Value2, + } + + public partial struct MyStruct + { + [NativeTypeName("enum_t")] + public MyEnum _field; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertyBackingTypeTestUnix.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertyBackingTypeTestUnix.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..4f74534d --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertyBackingTypeTestUnix.CSharp.Latest.Unix.cs @@ -0,0 +1,96 @@ +namespace ClangSharp.Test +{ + public partial struct IntBitfield + { + public int _bitfield; + + [NativeTypeName("int : 8")] + public int bits + { + readonly get + { + return (_bitfield << 24) >> 24; + } + + set + { + _bitfield = (_bitfield & ~0xFF) | (value & 0xFF); + } + } + + [NativeTypeName("unsigned int : 8")] + public uint bits2 + { + readonly get + { + return (uint)((_bitfield >> 8) & 0xFF); + } + + set + { + _bitfield = (_bitfield & ~(0xFF << 8)) | (int)((value & 0xFFu) << 8); + } + } + } + + public partial struct UIntBitfield + { + public uint _bitfield; + + [NativeTypeName("unsigned int : 8")] + public uint bits1 + { + readonly get + { + return _bitfield & 0xFFu; + } + + set + { + _bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu); + } + } + + [NativeTypeName("int : 8")] + public int bits2 + { + readonly get + { + return (int)(_bitfield << 16) >> 24; + } + + set + { + _bitfield = (_bitfield & ~(0xFFu << 8)) | (uint)((value & 0xFF) << 8); + } + } + + [NativeTypeName("unsigned char : 8")] + public byte bits3 + { + readonly get + { + return (byte)((_bitfield >> 16) & 0xFFu); + } + + set + { + _bitfield = (_bitfield & ~(0xFFu << 16)) | (uint)((value & 0xFFu) << 16); + } + } + + [NativeTypeName("char : 8")] + public sbyte bits4 + { + readonly get + { + return (sbyte)((sbyte)(_bitfield << 0) >> 24); + } + + set + { + _bitfield = (_bitfield & ~(0xFFu << 24)) | (uint)((value & 0xFF) << 24); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertySmallBackingTypeTestUnix.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertySmallBackingTypeTestUnix.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..1575ef13 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertySmallBackingTypeTestUnix.CSharp.Latest.Unix.cs @@ -0,0 +1,53 @@ +namespace ClangSharp.Test +{ + public partial struct Bitfield + { + public byte _bitfield1; + + [NativeTypeName("unsigned char : 8")] + public byte bits1 + { + readonly get + { + return (byte)(_bitfield1 & 0xFFu); + } + + set + { + _bitfield1 = (byte)((_bitfield1 & ~0xFFu) | (value & 0xFFu)); + } + } + + public sbyte _bitfield2; + + [NativeTypeName("char : 8")] + public sbyte bits2 + { + readonly get + { + return (sbyte)((_bitfield2 << 0) >> 0); + } + + set + { + _bitfield2 = (sbyte)((_bitfield2 & ~0xFF) | (value & 0xFF)); + } + } + + public byte _bitfield3; + + [NativeTypeName("unsigned char : 8")] + public byte bits3 + { + readonly get + { + return (byte)(_bitfield3 & 0xFFu); + } + + set + { + _bitfield3 = (byte)((_bitfield3 & ~0xFFu) | (value & 0xFFu)); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertyTypeCastTestUnix.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertyTypeCastTestUnix.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..b901fafe --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertyTypeCastTestUnix.CSharp.Latest.Unix.cs @@ -0,0 +1,41 @@ +namespace ClangSharp.Test +{ + [NativeTypeName("unsigned int")] + public enum Flags : uint + { + Member = 0x7FFFFFFF, + } + + public partial struct Bitfield + { + public uint _bitfield; + + [NativeTypeName("unsigned int : 8")] + public uint bits + { + readonly get + { + return _bitfield & 0xFFu; + } + + set + { + _bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu); + } + } + + [NativeTypeName("Flags : 8")] + public Flags flags + { + readonly get + { + return (Flags)((_bitfield >> 8) & 0xFFu); + } + + set + { + _bitfield = (_bitfield & ~(0xFFu << 8)) | (((uint)(value) & 0xFFu) << 8); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertyTypeCastTestWindows.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertyTypeCastTestWindows.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..1c543546 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumPropertyTypeCastTestWindows.CSharp.Latest.Windows.cs @@ -0,0 +1,40 @@ +namespace ClangSharp.Test +{ + public enum Flags + { + Member = 0x7FFFFFFF, + } + + public partial struct Bitfield + { + public uint _bitfield; + + [NativeTypeName("unsigned int : 8")] + public uint bits + { + readonly get + { + return _bitfield & 0xFFu; + } + + set + { + _bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu); + } + } + + [NativeTypeName("Flags : 8")] + public Flags flags + { + readonly get + { + return (Flags)((_bitfield << 16) >> 24); + } + + set + { + _bitfield = (_bitfield & ~(0xFFu << 8)) | (((uint)(value) & 0xFF) << 8); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumTypeDefPropertyTypeCast.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumTypeDefPropertyTypeCast.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..72e67926 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumTypeDefPropertyTypeCast.CSharp.Latest.Unix.cs @@ -0,0 +1,41 @@ +namespace ClangSharp.Test +{ + [NativeTypeName("unsigned int")] + public enum FlagBits : uint + { + Member = 0x7FFFFFFF, + } + + public partial struct Bitfield + { + public uint _bitfield; + + [NativeTypeName("unsigned int : 8")] + public uint bits + { + readonly get + { + return _bitfield & 0xFFu; + } + + set + { + _bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu); + } + } + + [NativeTypeName("Flags : 8")] + public uint flags + { + readonly get + { + return (_bitfield >> 8) & 0xFFu; + } + + set + { + _bitfield = (_bitfield & ~(0xFFu << 8)) | ((value & 0xFFu) << 8); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumTypeDefPropertyTypeCastWithRemappingTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumTypeDefPropertyTypeCastWithRemappingTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..8c01a697 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumTypeDefPropertyTypeCastWithRemappingTest.CSharp.Latest.Unix.cs @@ -0,0 +1,41 @@ +namespace ClangSharp.Test +{ + [NativeTypeName("unsigned int")] + public enum FlagBits : uint + { + Member = 0x7FFFFFFF, + } + + public partial struct Bitfield + { + public uint _bitfield; + + [NativeTypeName("unsigned int : 8")] + public uint bits + { + readonly get + { + return _bitfield & 0xFFu; + } + + set + { + _bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu); + } + } + + [NativeTypeName("Flags : 8")] + public FlagBits flags + { + readonly get + { + return (FlagBits)((_bitfield >> 8) & 0xFFu); + } + + set + { + _bitfield = (_bitfield & ~(0xFFu << 8)) | (((uint)(value) & 0xFFu) << 8); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumTypeDefPropertyTypeCastWithSelfRemappingTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumTypeDefPropertyTypeCastWithSelfRemappingTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..2c169315 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldEnumTypeDefPropertyTypeCastWithSelfRemappingTest.CSharp.Latest.Unix.cs @@ -0,0 +1,35 @@ +namespace ClangSharp.Test +{ + public partial struct Bitfield + { + public uint _bitfield; + + [NativeTypeName("unsigned int : 8")] + public uint bits + { + readonly get + { + return _bitfield & 0xFFu; + } + + set + { + _bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu); + } + } + + [NativeTypeName("Flags : 8")] + public Flags flags + { + readonly get + { + return (Flags)((_bitfield >> 8) & 0xFFu); + } + + set + { + _bitfield = (_bitfield & ~(0xFFu << 8)) | (((uint)(value) & 0xFFu) << 8); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldTypeDefTypeCastTestUnix.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldTypeDefTypeCastTestUnix.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..c7d8a8b3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/BitfieldTypeDefTypeCastTestUnix.CSharp.Latest.Unix.cs @@ -0,0 +1,21 @@ +namespace ClangSharp.Test +{ + public partial struct Bitfield + { + public uint _bitfield; + + [NativeTypeName("Number : 8")] + public uint bits + { + readonly get + { + return _bitfield & 0xFFu; + } + + set + { + _bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu); + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/CLongDefinesRegressionTestUnix.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/CLongDefinesRegressionTestUnix.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..e1295a25 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/CLongDefinesRegressionTestUnix.CSharp.Latest.Unix.cs @@ -0,0 +1,23 @@ +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + [return: NativeTypeName("_Bool")] + public static bool SDL_size_add_check_overflow([NativeTypeName("size_t")] nuint a, [NativeTypeName("size_t")] nuint b, [NativeTypeName("size_t *")] nuint* ret) + { + if (b > unchecked(18446744073709551615U) - a) + { + return (0) != 0; + } + + *ret = a + b; + return (1) != 0; + } + + [NativeTypeName("#define true 1")] + public const int @true = 1; + + [NativeTypeName("#define false 0")] + public const int @false = 0; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/CLongDefinesTestUnix.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/CLongDefinesTestUnix.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..caaadc68 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/CLongDefinesTestUnix.CSharp.Latest.Unix.cs @@ -0,0 +1,32 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define SIZE_MAX (18446744073709551615UL)")] + public static readonly nuint SIZE_MAX = unchecked((nuint)(18446744073709551615U)); + + [NativeTypeName("#define CL_IMPORT_MEMORY_WHOLE_ALLOCATION_ARM SIZE_MAX")] + public static readonly nuint CL_IMPORT_MEMORY_WHOLE_ALLOCATION_ARM = unchecked((nuint)(18446744073709551615U)); + + [NativeTypeName("#define LONG_MAX __LONG_MAX__")] + public static readonly nint LONG_MAX = unchecked((nint)(9223372036854775807)); + + [NativeTypeName("#define ULONG_MAX (__LONG_MAX__ *2UL+1UL)")] + public static readonly nuint ULONG_MAX = unchecked((nuint)(9223372036854775807 * 2U + 1U)); + + [NativeTypeName("#define CONST_IN_RANGE_S1 ((long)2147483647)")] + public const nint CONST_IN_RANGE_S1 = ((nint)(2147483647)); + + [NativeTypeName("#define CONST_IN_RANGE_U1 ((unsigned long)4294967295)")] + public const nuint CONST_IN_RANGE_U1 = ((nuint)(4294967295)); + + [NativeTypeName("#define READONLY_OUT_OF_RANGE_S1 ((long)4294967295)")] + public static readonly nint READONLY_OUT_OF_RANGE_S1 = unchecked((nint)(4294967295)); + + [NativeTypeName("#define READONLY_OUT_OF_RANGE_S2 ((long)4294967296)")] + public static readonly nint READONLY_OUT_OF_RANGE_S2 = unchecked((nint)(4294967296)); + + [NativeTypeName("#define READONLY_OUT_OF_RANGE_U1 ((unsigned long)4294967296)")] + public static readonly nuint READONLY_OUT_OF_RANGE_U1 = unchecked((nuint)(4294967296)); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/CLongDefinesTestWindows.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/CLongDefinesTestWindows.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..f1db8cc3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/CLongDefinesTestWindows.CSharp.Latest.Windows.cs @@ -0,0 +1,17 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define SIZE_MAX 0xffffffffffffffffui64")] + public const ulong SIZE_MAX = 0xffffffffffffffffUL; + + [NativeTypeName("#define CL_IMPORT_MEMORY_WHOLE_ALLOCATION_ARM SIZE_MAX")] + public const ulong CL_IMPORT_MEMORY_WHOLE_ALLOCATION_ARM = 0xffffffffffffffffUL; + + [NativeTypeName("#define LONG_MAX 2147483647L")] + public const int LONG_MAX = 2147483647; + + [NativeTypeName("#define ULONG_MAX 0xffffffffUL")] + public const uint ULONG_MAX = 0xffffffffU; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/EnumTest.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/EnumTest.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..22045657 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/EnumTest.CSharp.Latest.Unix.cs @@ -0,0 +1,19 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("__AnonymousEnum_ClangUnsavedFile_L8_C5")] + public uint field; + + public const uint VALUEA = 0; + public const uint VALUEB = 1; + public const uint VALUEC = 2; + } + + public static partial class Methods + { + public const uint VALUE1 = 0; + public const uint VALUE2 = 1; + public const uint VALUE3 = 2; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/EnumTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/EnumTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..a9bbb306 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/EnumTest.CSharp.Latest.Windows.cs @@ -0,0 +1,19 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + [NativeTypeName("__AnonymousEnum_ClangUnsavedFile_L8_C5")] + public int field; + + public const int VALUEA = 0; + public const int VALUEB = 1; + public const int VALUEC = 2; + } + + public static partial class Methods + { + public const int VALUE1 = 0; + public const int VALUE2 = 1; + public const int VALUE3 = 2; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/MacroTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/MacroTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..d1100643 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/MacroTest.CSharp.Latest.Windows.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("#define MyMacro1 5")] + public const int MyMacro1 = 5; + + [NativeTypeName("#define MyMacro2 MyMacro1")] + public const int MyMacro2 = 5; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/StructTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/StructTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..a08172e5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/StructTest.CSharp.Latest.Windows.cs @@ -0,0 +1,45 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public partial struct _MyStruct + { + public int _field; + } + + public unsafe partial struct _MyOtherStruct + { + [NativeTypeName("MyStruct")] + public _MyStruct _field1; + + [NativeTypeName("MyStruct *")] + public _MyStruct* _field2; + } + + public partial struct _MyStructWithAnonymousStruct + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L14_C5")] + public __anonymousStructField1_e__Struct _anonymousStructField1; + + public partial struct __anonymousStructField1_e__Struct + { + public int _field; + } + } + + public partial struct _MyStructWithAnonymousUnion + { + [NativeTypeName("__AnonymousRecord_ClangUnsavedFile_L21_C5")] + public _union1_e__Union union1; + + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct _union1_e__Union + { + [FieldOffset(0)] + public int _field1; + + [FieldOffset(0)] + public int* _field2; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/UnionTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/UnionTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..e7226974 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/UnionTest.CSharp.Latest.Windows.cs @@ -0,0 +1,23 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct _MyUnion + { + [FieldOffset(0)] + public int _field; + } + + [StructLayout(LayoutKind.Explicit)] + public unsafe partial struct _MyOtherUnion + { + [FieldOffset(0)] + [NativeTypeName("MyUnion")] + public _MyUnion _field1; + + [FieldOffset(0)] + [NativeTypeName("MyUnion *")] + public _MyUnion* _field2; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/UnsignedIntBitshiftTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/UnsignedIntBitshiftTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..b2732539 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/UnsignedIntBitshiftTest.CSharp.Latest.Windows.cs @@ -0,0 +1,89 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const int")] + public const int Signed = 1; + + [NativeTypeName("const long")] + public const int SignedLong = 1; + + [NativeTypeName("const unsigned int")] + public const uint Unsigned = 1; + + [NativeTypeName("const int")] + public const int ShiftSigned = 1 << Signed; + + [NativeTypeName("const int")] + public const int ShiftSignedLong = 1 << SignedLong; + + [NativeTypeName("const int")] + public const int ShiftUnsigned = 1 << (int)(Unsigned); + + [NativeTypeName("const int")] + public const int Char = 1 << (sbyte)('a'); + + [NativeTypeName("const int")] + public const int Byte = 1 << (sbyte)(1); + + [NativeTypeName("const int")] + public const int UByte = unchecked(1 << (byte)(1)); + + [NativeTypeName("const int")] + public const int CInt = 1 << 1; + + [NativeTypeName("const int")] + public const int CUint = 1 << 1; + + [NativeTypeName("const int")] + public const int Negative = 1 << -1; + + [NativeTypeName("const int")] + public const int OutOfRangePos = unchecked(1 << (int)(10000000000)); + + [NativeTypeName("const int")] + public const int OutOfRangeNeg = unchecked(1 << (int)(-10000000000)); + + [NativeTypeName("const int")] + public const int IntMax = 1 << 2147483647; + + [NativeTypeName("const int")] + public const int IntMin = unchecked(1 << -2147483648); + + [NativeTypeName("const int")] + public const int LongMax = unchecked(1 << (int)(9223372036854775807)); + + [NativeTypeName("const int")] + public const int LongMin = unchecked(1 << (int)(-9223372036854775808)); + + [NativeTypeName("const int")] + public const int ULongMax = 1 << -1; + + [NativeTypeName("const int")] + public const int Hexadecimal = 1 << 1; + + [NativeTypeName("#define Left 1 << 1U")] + public const int Left = 1 << 1; + + [NativeTypeName("#define Right 1 >> 1U")] + public const int Right = 1 >> 1; + + [NativeTypeName("#define Int 1 << 1")] + public const int Int = 1 << 1; + + [NativeTypeName("#define Long 1 << 1L")] + public const int Long = 1 << 1; + + [NativeTypeName("#define LongLong 1 << 1LL")] + public const int LongLong = 1 << 1; + + [NativeTypeName("#define ULong 1 << 1UL")] + public const int ULong = 1 << 1; + + [NativeTypeName("#define ULongLong 1 << 1ULL")] + public const int ULongLong = 1 << 1; + + [NativeTypeName("#define Complex ((((unsigned int)(0)) << 29U) | (((unsigned int)(1)) << 22U) | (((unsigned int)(0)) << 12U) | ((unsigned int)(0)))")] + public const uint Complex = ((((uint)(0)) << 29) | (((uint)(1)) << 22) | (((uint)(0)) << 12) | ((uint)(0))); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/UnsignedIntBitshiftTestUnix.CSharp.Latest.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/UnsignedIntBitshiftTestUnix.CSharp.Latest.Unix.cs new file mode 100644 index 00000000..21229d9b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/UnsignedIntBitshiftTestUnix.CSharp.Latest.Unix.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public static partial class Methods + { + [NativeTypeName("const long")] + public const nint SignedLong = 1; + + [NativeTypeName("const int")] + public const int ShiftSignedLong = 1 << (int)(SignedLong); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/VoidPointerArithmeticTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/VoidPointerArithmeticTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..26a72578 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/C/VoidPointerArithmeticTest.CSharp.Latest.Windows.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + public static void* MyFunction(void* buf, [NativeTypeName("unsigned long long")] ulong size) + { + return (byte*)buf + size; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedAdjacentString/AdjacentStringLiteralsAreConcatenated.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedAdjacentString/AdjacentStringLiteralsAreConcatenated.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..d2c6862e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/DeprecatedAdjacentString/AdjacentStringLiteralsAreConcatenated.CSharp.Latest.Windows.cs @@ -0,0 +1,12 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [Obsolete("Use Bar() or Baz() instead")] + public static extern void MyFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FileScopedNamespace/MembersAfterFirstAreNotOverIndented.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FileScopedNamespace/MembersAfterFirstAreNotOverIndented.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..0eebe990 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FileScopedNamespace/MembersAfterFirstAreNotOverIndented.CSharp.Latest.Windows.cs @@ -0,0 +1,22 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test; + +public partial struct Point +{ + public int x; + + public int y; +} + +public enum Color +{ + Red, + Green, +} + +public static partial class Methods +{ + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(); +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FileScopedNamespace/MethodClassHasNoTrailingBrace.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FileScopedNamespace/MethodClassHasNoTrailingBrace.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..d3da22d7 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FileScopedNamespace/MethodClassHasNoTrailingBrace.CSharp.Latest.Windows.cs @@ -0,0 +1,9 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test; + +public static partial class Methods +{ + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(); +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FileScopedNamespace/StructHasNoTrailingBrace.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FileScopedNamespace/StructHasNoTrailingBrace.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..d88702e0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FileScopedNamespace/StructHasNoTrailingBrace.CSharp.Latest.Windows.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test; + +public partial struct Point +{ + public int x; + + public int y; +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FixedBufferIndexerOverloads/GeneratesOnlyIntIndexerWhenDisabled.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FixedBufferIndexerOverloads/GeneratesOnlyIntIndexerWhenDisabled.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..21094ff5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FixedBufferIndexerOverloads/GeneratesOnlyIntIndexerWhenDisabled.CSharp.Compatible.Windows.cs @@ -0,0 +1,31 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FixedBufferIndexerOverloads/GeneratesOverloadsWhenEnabled.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FixedBufferIndexerOverloads/GeneratesOverloadsWhenEnabled.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..8b32f940 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FixedBufferIndexerOverloads/GeneratesOverloadsWhenEnabled.CSharp.Compatible.Windows.cs @@ -0,0 +1,64 @@ +namespace ClangSharp.Test +{ + public partial struct MyStruct + { + public int value; + } + + public partial struct MyOtherStruct + { + [NativeTypeName("MyStruct[3]")] + public _c_e__FixedBuffer c; + + public partial struct _c_e__FixedBuffer + { + public MyStruct e0; + public MyStruct e1; + public MyStruct e2; + + public unsafe ref MyStruct this[int index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + + public unsafe ref MyStruct this[uint index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + + public unsafe ref MyStruct this[nint index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + + public unsafe ref MyStruct this[nuint index] + { + get + { + fixed (MyStruct* pThis = &e0) + { + return ref pThis[index]; + } + } + } + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerRemap/RemappedFnptrTypedefFieldStaysIntPtrUnix.CSharp.Compatible.Unix.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerRemap/RemappedFnptrTypedefFieldStaysIntPtrUnix.CSharp.Compatible.Unix.cs new file mode 100644 index 00000000..adc2a0e2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerRemap/RemappedFnptrTypedefFieldStaysIntPtrUnix.CSharp.Compatible.Unix.cs @@ -0,0 +1,14 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void PFoo(int param0); + + public partial struct Callbacks + { + [NativeTypeName("ApiPFoo *")] + public IntPtr Foo; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerRemap/RemappedFnptrTypedefFieldStaysIntPtrWindows.CSharp.Compatible.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerRemap/RemappedFnptrTypedefFieldStaysIntPtrWindows.CSharp.Compatible.Windows.cs new file mode 100644 index 00000000..adc2a0e2 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/FunctionPointerRemap/RemappedFnptrTypedefFieldStaysIntPtrWindows.CSharp.Compatible.Windows.cs @@ -0,0 +1,14 @@ +using System; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void PFoo(int param0); + + public partial struct Callbacks + { + [NativeTypeName("ApiPFoo *")] + public IntPtr Foo; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/GlobalStructInitializer/NonConstGlobalTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/GlobalStructInitializer/NonConstGlobalTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..91ad6a3f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/GlobalStructInitializer/NonConstGlobalTest.CSharp.Latest.Windows.cs @@ -0,0 +1,18 @@ +namespace ClangSharp.Test +{ + public partial struct Point + { + public int x; + + public int y; + } + + public static partial class Methods + { + public static Point MyGlobalPoint = new Point + { + x = 10, + y = 20, + }; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedAfterMethodClass.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedAfterMethodClass.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..9051b364 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedAfterMethodClass.CSharp.Latest.Windows.cs @@ -0,0 +1,57 @@ +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct SRC_DATA + { + [NativeTypeName("const float *")] + public float* data_in; + + [NativeTypeName("long")] + public int input_frames; + } + + public static partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(); + } + + /// Defines the type of a member as it was used in the native signature. + [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] + [Conditional("DEBUG")] + internal sealed partial class NativeTypeNameAttribute : Attribute + { + private readonly string _name; + + /// Initializes a new instance of the class. + /// The name of the type that was used in the native signature. + public NativeTypeNameAttribute(string name) + { + _name = name; + } + + /// Gets the name of the type that was used in the native signature. + public string Name => _name; + } + + /// Defines the annotation found in a native declaration. + [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] + [Conditional("DEBUG")] + internal sealed partial class NativeAnnotationAttribute : Attribute + { + private readonly string _annotation; + + /// Initializes a new instance of the class. + /// The annotation that was used in the native declaration. + public NativeAnnotationAttribute(string annotation) + { + _annotation = annotation; + } + + /// Gets the annotation that was used in the native declaration. + public string Annotation => _annotation; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedAfterMethodClassFileScoped.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedAfterMethodClassFileScoped.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..8f6ba8d5 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedAfterMethodClassFileScoped.CSharp.Latest.Windows.cs @@ -0,0 +1,56 @@ +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace ClangSharp.Test; + +public unsafe partial struct SRC_DATA +{ + [NativeTypeName("const float *")] + public float* data_in; + + [NativeTypeName("long")] + public int input_frames; +} + +public static partial class Methods +{ + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction(); +} + +/// Defines the type of a member as it was used in the native signature. +[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] +[Conditional("DEBUG")] +internal sealed partial class NativeTypeNameAttribute : Attribute +{ + private readonly string _name; + + /// Initializes a new instance of the class. + /// The name of the type that was used in the native signature. + public NativeTypeNameAttribute(string name) + { + _name = name; + } + + /// Gets the name of the type that was used in the native signature. + public string Name => _name; +} + +/// Defines the annotation found in a native declaration. +[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] +[Conditional("DEBUG")] +internal sealed partial class NativeAnnotationAttribute : Attribute +{ + private readonly string _annotation; + + /// Initializes a new instance of the class. + /// The annotation that was used in the native declaration. + public NativeAnnotationAttribute(string annotation) + { + _annotation = annotation; + } + + /// Gets the annotation that was used in the native declaration. + public string Annotation => _annotation; +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedInSharedFileScopedNamespace.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedInSharedFileScopedNamespace.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..43ca195f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedInSharedFileScopedNamespace.CSharp.Latest.Windows.cs @@ -0,0 +1,49 @@ +using System; +using System.Diagnostics; + +namespace ClangSharp.Test; + +public unsafe partial struct SRC_DATA +{ + [NativeTypeName("const float *")] + public float* data_in; + + [NativeTypeName("long")] + public int input_frames; +} + +/// Defines the type of a member as it was used in the native signature. +[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] +[Conditional("DEBUG")] +internal sealed partial class NativeTypeNameAttribute : Attribute +{ + private readonly string _name; + + /// Initializes a new instance of the class. + /// The name of the type that was used in the native signature. + public NativeTypeNameAttribute(string name) + { + _name = name; + } + + /// Gets the name of the type that was used in the native signature. + public string Name => _name; +} + +/// Defines the annotation found in a native declaration. +[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] +[Conditional("DEBUG")] +internal sealed partial class NativeAnnotationAttribute : Attribute +{ + private readonly string _annotation; + + /// Initializes a new instance of the class. + /// The annotation that was used in the native declaration. + public NativeAnnotationAttribute(string annotation) + { + _annotation = annotation; + } + + /// Gets the annotation that was used in the native declaration. + public string Annotation => _annotation; +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedInSharedNamespace.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedInSharedNamespace.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..719c4991 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/HelperTypes/HelperTypesEmittedInSharedNamespace.CSharp.Latest.Windows.cs @@ -0,0 +1,50 @@ +using System; +using System.Diagnostics; + +namespace ClangSharp.Test +{ + public unsafe partial struct SRC_DATA + { + [NativeTypeName("const float *")] + public float* data_in; + + [NativeTypeName("long")] + public int input_frames; + } + + /// Defines the type of a member as it was used in the native signature. + [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] + [Conditional("DEBUG")] + internal sealed partial class NativeTypeNameAttribute : Attribute + { + private readonly string _name; + + /// Initializes a new instance of the class. + /// The name of the type that was used in the native signature. + public NativeTypeNameAttribute(string name) + { + _name = name; + } + + /// Gets the name of the type that was used in the native signature. + public string Name => _name; + } + + /// Defines the annotation found in a native declaration. + [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] + [Conditional("DEBUG")] + internal sealed partial class NativeAnnotationAttribute : Attribute + { + private readonly string _annotation; + + /// Initializes a new instance of the class. + /// The annotation that was used in the native declaration. + public NativeAnnotationAttribute(string annotation) + { + _annotation = annotation; + } + + /// Gets the annotation that was used in the native declaration. + public string Annotation => _annotation; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/DispatchesNonPrimaryBaseThroughSubobject.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/DispatchesNonPrimaryBaseThroughSubobject.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..ab67a951 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/DispatchesNonPrimaryBaseThroughSubobject.CSharp.Latest.Windows.cs @@ -0,0 +1,42 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct Foo + { + public void** lpVtbl; + + public void FooMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Foo*)Unsafe.AsPointer(ref this)); + } + } + + public unsafe partial struct Bar + { + public void** lpVtbl; + + public void BarMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Bar*)Unsafe.AsPointer(ref this)); + } + } + + [NativeTypeName("struct Baz : Foo, Bar")] + public unsafe partial struct Baz + { + public void** lpVtbl; + + public Bar Base2; + + public void FooMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Baz*)Unsafe.AsPointer(ref this)); + } + + public void BazMethod() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((Baz*)Unsafe.AsPointer(ref this)); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/EmitsFieldBearingPrimaryBaseAsSubobject.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/EmitsFieldBearingPrimaryBaseAsSubobject.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..2f695c1c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/EmitsFieldBearingPrimaryBaseAsSubobject.CSharp.Latest.Windows.cs @@ -0,0 +1,34 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct Foo + { + public void** lpVtbl; + + public int x; + + public void A() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Foo*)Unsafe.AsPointer(ref this)); + } + } + + public unsafe partial struct Bar + { + public void** lpVtbl; + + public void B() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Bar*)Unsafe.AsPointer(ref this)); + } + } + + [NativeTypeName("struct Baz : Foo, Bar")] + public partial struct Baz + { + public Foo Base1; + + public Bar Base2; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/EmitsSecondaryBaseAsSubobject.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/EmitsSecondaryBaseAsSubobject.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..6a6f024e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/EmitsSecondaryBaseAsSubobject.CSharp.Latest.Windows.cs @@ -0,0 +1,37 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct Foo + { + public void** lpVtbl; + + public void Dispose() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Foo*)Unsafe.AsPointer(ref this)); + } + } + + public unsafe partial struct Bar + { + public void** lpVtbl; + + public void Dispose() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Bar*)Unsafe.AsPointer(ref this)); + } + } + + [NativeTypeName("struct Baz : Foo, Bar")] + public unsafe partial struct Baz + { + public void** lpVtbl; + + public Bar Base2; + + public void Dispose() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Baz*)Unsafe.AsPointer(ref this)); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/EmitsSecondaryBaseAsSubobjectWithExplicitVtbls.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/EmitsSecondaryBaseAsSubobjectWithExplicitVtbls.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..e719829e --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/EmitsSecondaryBaseAsSubobjectWithExplicitVtbls.CSharp.Latest.Windows.cs @@ -0,0 +1,55 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct Foo + { + public Vtbl* lpVtbl; + + public void Dispose() + { + lpVtbl->Dispose((Foo*)Unsafe.AsPointer(ref this)); + } + + public partial struct Vtbl + { + [NativeTypeName("void () noexcept")] + public delegate* unmanaged[Thiscall] Dispose; + } + } + + public unsafe partial struct Bar + { + public Vtbl* lpVtbl; + + public void Dispose() + { + lpVtbl->Dispose((Bar*)Unsafe.AsPointer(ref this)); + } + + public partial struct Vtbl + { + [NativeTypeName("void () noexcept")] + public delegate* unmanaged[Thiscall] Dispose; + } + } + + [NativeTypeName("struct Baz : Foo, Bar")] + public unsafe partial struct Baz + { + public Vtbl* lpVtbl; + + public Bar Base2; + + public void Dispose() + { + lpVtbl->Dispose((Baz*)Unsafe.AsPointer(ref this)); + } + + public partial struct Vtbl + { + [NativeTypeName("void () noexcept")] + public delegate* unmanaged[Thiscall] Dispose; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/FallsBackToFlattenedVtblForNestedMultipleInheritance.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/FallsBackToFlattenedVtblForNestedMultipleInheritance.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..fe174f66 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/FallsBackToFlattenedVtblForNestedMultipleInheritance.CSharp.Latest.Windows.cs @@ -0,0 +1,68 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct A + { + public void** lpVtbl; + + public void a() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((A*)Unsafe.AsPointer(ref this)); + } + } + + public unsafe partial struct B + { + public void** lpVtbl; + + public void b() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((B*)Unsafe.AsPointer(ref this)); + } + } + + [NativeTypeName("struct C : A, B")] + public unsafe partial struct C + { + public void** lpVtbl; + + public B Base2; + + public void a() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((C*)Unsafe.AsPointer(ref this)); + } + + public void c() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((C*)Unsafe.AsPointer(ref this)); + } + } + + [NativeTypeName("struct D : C")] + public unsafe partial struct D + { + public void** lpVtbl; + + public void a() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((D*)Unsafe.AsPointer(ref this)); + } + + public void b() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((D*)Unsafe.AsPointer(ref this)); + } + + public void c() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((D*)Unsafe.AsPointer(ref this)); + } + + public void d() + { + ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((D*)Unsafe.AsPointer(ref this)); + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/InheritsPrimaryBaseMarkerInterfaceOnly.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/InheritsPrimaryBaseMarkerInterfaceOnly.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..8167169b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/MultipleBaseVtblSubobject/InheritsPrimaryBaseMarkerInterfaceOnly.CSharp.Latest.Windows.cs @@ -0,0 +1,81 @@ +using System.Runtime.CompilerServices; + +namespace ClangSharp.Test +{ + public unsafe partial struct Foo : Foo.Interface + { + public Vtbl* lpVtbl; + + public void FooMethod() + { + lpVtbl->FooMethod((Foo*)Unsafe.AsPointer(ref this)); + } + + public interface Interface + { + void FooMethod(); + } + + public partial struct Vtbl + where TSelf : unmanaged, Interface + { + [NativeTypeName("void ()")] + public delegate* unmanaged[Thiscall] FooMethod; + } + } + + public unsafe partial struct Bar : Bar.Interface + { + public Vtbl* lpVtbl; + + public void BarMethod() + { + lpVtbl->BarMethod((Bar*)Unsafe.AsPointer(ref this)); + } + + public interface Interface + { + void BarMethod(); + } + + public partial struct Vtbl + where TSelf : unmanaged, Interface + { + [NativeTypeName("void ()")] + public delegate* unmanaged[Thiscall] BarMethod; + } + } + + [NativeTypeName("struct Baz : Foo, Bar")] + public unsafe partial struct Baz : Baz.Interface + { + public Vtbl* lpVtbl; + + public Bar Base2; + + public void FooMethod() + { + lpVtbl->FooMethod((Baz*)Unsafe.AsPointer(ref this)); + } + + public void BazMethod() + { + lpVtbl->BazMethod((Baz*)Unsafe.AsPointer(ref this)); + } + + public interface Interface : Foo.Interface + { + void BazMethod(); + } + + public partial struct Vtbl + where TSelf : unmanaged, Interface + { + [NativeTypeName("void ()")] + public delegate* unmanaged[Thiscall] FooMethod; + + [NativeTypeName("void ()")] + public delegate* unmanaged[Thiscall] BazMethod; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/NestedTypeReference/NestedTypeIsQualified.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/NestedTypeReference/NestedTypeIsQualified.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..b922754f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/NestedTypeReference/NestedTypeIsQualified.CSharp.Latest.Windows.cs @@ -0,0 +1,17 @@ +namespace ClangSharp.Test +{ + public partial struct A + { + + public partial struct Inner + { + public int value; + } + } + + public partial struct B + { + [NativeTypeName("A::Inner")] + public A.Inner inner; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/NullPtrMacroBinding/NullPtrMacroTest.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/NullPtrMacroBinding/NullPtrMacroTest.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..53ce4678 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/NullPtrMacroBinding/NullPtrMacroTest.CSharp.Latest.Windows.cs @@ -0,0 +1,8 @@ +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + [NativeTypeName("#define MY_NULL_HANDLE nullptr")] + public static readonly void* MY_NULL_HANDLE = null; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/Options/WithAttributes.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/Options/WithAttributes.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..2fa00c8f --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/Options/WithAttributes.CSharp.Latest.Windows.cs @@ -0,0 +1,22 @@ +namespace ClangSharp.Test +{ + [A] + public partial struct StructA + { + } + + [B] + public partial struct StructB + { + } + + [Star] + public partial struct StructC + { + } + + [Star] + public partial struct StructD + { + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/Options/WithUsings.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/Options/WithUsings.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..7b282d5c --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/Options/WithUsings.CSharp.Latest.Windows.cs @@ -0,0 +1,24 @@ +using ForStar; +using ForStructA1; +using ForStructA2; +using ForStructBWithDoubleColon; +using ForStructCWithDot; + +namespace ClangSharp.Test +{ + public partial struct StructA + { + } + + public partial struct StructB + { + } + + public partial struct StructC + { + } + + public partial struct StructD + { + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/SalFieldAttribute/FieldSalAnnotationGeneratesCppAttributeList.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/SalFieldAttribute/FieldSalAnnotationGeneratesCppAttributeList.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..d1e5a404 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/SalFieldAttribute/FieldSalAnnotationGeneratesCppAttributeList.CSharp.Latest.Windows.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public unsafe partial struct MyStruct + { + public int count; + + [CppAttributeList("_Field_size_full_(count)")] + [NativeAnnotation("_Field_size_full_(count)")] + public int* data; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StripEnumMemberReference/SiblingReferencesAreStripped.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StripEnumMemberReference/SiblingReferencesAreStripped.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..2f494c42 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/StripEnumMemberReference/SiblingReferencesAreStripped.CSharp.Latest.Windows.cs @@ -0,0 +1,11 @@ +namespace ClangSharp.Test +{ + public enum WGPUInstanceBackend + { + Vulkan = 1 << 0, + GL = 1 << 1, + Metal = 1 << 2, + Primary = Vulkan | Metal, + Secondary = GL, + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/TransparentStruct/BooleanKindGeneratesValidHelper.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/TransparentStruct/BooleanKindGeneratesValidHelper.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..c5b15dee --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/TransparentStruct/BooleanKindGeneratesValidHelper.CSharp.Latest.Windows.cs @@ -0,0 +1,137 @@ +using System; +using System.Diagnostics; + +namespace ClangSharp.Test +{ + /// Defines the type of a member as it was used in the native signature. + [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] + [Conditional("DEBUG")] + internal sealed partial class NativeTypeNameAttribute : Attribute + { + private readonly string _name; + + /// Initializes a new instance of the class. + /// The name of the type that was used in the native signature. + public NativeTypeNameAttribute(string name) + { + _name = name; + } + + /// Gets the name of the type that was used in the native signature. + public string Name => _name; + } + + /// Defines the annotation found in a native declaration. + [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] + [Conditional("DEBUG")] + internal sealed partial class NativeAnnotationAttribute : Attribute + { + private readonly string _annotation; + + /// Initializes a new instance of the class. + /// The annotation that was used in the native declaration. + public NativeAnnotationAttribute(string annotation) + { + _annotation = annotation; + } + + /// Gets the annotation that was used in the native declaration. + public string Annotation => _annotation; + } + + public readonly partial struct MyBoolean : IComparable, IComparable, IEquatable, IFormattable + { + public readonly byte Value; + + public MyBoolean(byte value) + { + Value = value; + } + + public static MyBoolean FALSE => new MyBoolean(0); + + public static MyBoolean TRUE => new MyBoolean(1); + + public static bool operator ==(MyBoolean left, MyBoolean right) => left.Value == right.Value; + + public static bool operator !=(MyBoolean left, MyBoolean right) => left.Value != right.Value; + + public static bool operator <(MyBoolean left, MyBoolean right) => left.Value < right.Value; + + public static bool operator <=(MyBoolean left, MyBoolean right) => left.Value <= right.Value; + + public static bool operator >(MyBoolean left, MyBoolean right) => left.Value > right.Value; + + public static bool operator >=(MyBoolean left, MyBoolean right) => left.Value >= right.Value; + + public static implicit operator bool(MyBoolean value) => value.Value != 0; + + public static implicit operator MyBoolean(bool value) => new MyBoolean((byte)(value ? 1u : 0u)); + + public static bool operator false(MyBoolean value) => value.Value == 0; + + public static bool operator true(MyBoolean value) => value.Value != 0; + + public static implicit operator MyBoolean(byte value) => new MyBoolean(value); + + public static implicit operator byte(MyBoolean value) => value.Value; + + public static explicit operator MyBoolean(short value) => new MyBoolean(unchecked((byte)(value))); + + public static implicit operator short(MyBoolean value) => value.Value; + + public static explicit operator MyBoolean(int value) => new MyBoolean(unchecked((byte)(value))); + + public static implicit operator int(MyBoolean value) => value.Value; + + public static explicit operator MyBoolean(long value) => new MyBoolean(unchecked((byte)(value))); + + public static implicit operator long(MyBoolean value) => value.Value; + + public static explicit operator MyBoolean(nint value) => new MyBoolean(unchecked((byte)(value))); + + public static implicit operator nint(MyBoolean value) => value.Value; + + public static explicit operator MyBoolean(sbyte value) => new MyBoolean(unchecked((byte)(value))); + + public static explicit operator sbyte(MyBoolean value) => (sbyte)(value.Value); + + public static explicit operator MyBoolean(ushort value) => new MyBoolean(unchecked((byte)(value))); + + public static implicit operator ushort(MyBoolean value) => value.Value; + + public static explicit operator MyBoolean(uint value) => new MyBoolean(unchecked((byte)(value))); + + public static implicit operator uint(MyBoolean value) => value.Value; + + public static explicit operator MyBoolean(ulong value) => new MyBoolean(unchecked((byte)(value))); + + public static implicit operator ulong(MyBoolean value) => value.Value; + + public static explicit operator MyBoolean(nuint value) => new MyBoolean(unchecked((byte)(value))); + + public static implicit operator nuint(MyBoolean value) => value.Value; + + public int CompareTo(object? obj) + { + if (obj is MyBoolean other) + { + return CompareTo(other); + } + + return (obj is null) ? 1 : throw new ArgumentException("obj is not an instance of MyBoolean."); + } + + public int CompareTo(MyBoolean other) => Value.CompareTo(other.Value); + + public override bool Equals(object? obj) => (obj is MyBoolean other) && Equals(other); + + public bool Equals(MyBoolean other) => Value.Equals(other.Value); + + public override int GetHashCode() => Value.GetHashCode(); + + public override string ToString() => Value.ToString(); + + public string ToString(string? format, IFormatProvider? formatProvider) => Value.ToString(format, formatProvider); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionFieldTypeNameClash/AutoRenamesClashingTypeAndWarns.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionFieldTypeNameClash/AutoRenamesClashingTypeAndWarns.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..55f0e1e0 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionFieldTypeNameClash/AutoRenamesClashingTypeAndWarns.CSharp.Latest.Windows.cs @@ -0,0 +1,22 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct GpuCaptureUnion + { + [FieldOffset(0)] + [NativeTypeName("struct GpuCaptureParameters")] + public _GpuCaptureParameters_e__Struct GpuCaptureParameters; + + [FieldOffset(0)] + public int other; + + public partial struct _GpuCaptureParameters_e__Struct + { + public int a; + + public int b; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionFieldTypeNameClash/RemapFieldControlsClashingFieldName.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionFieldTypeNameClash/RemapFieldControlsClashingFieldName.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..81d4e191 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionFieldTypeNameClash/RemapFieldControlsClashingFieldName.CSharp.Latest.Windows.cs @@ -0,0 +1,22 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct GpuCaptureUnion + { + [FieldOffset(0)] + [NativeTypeName("struct GpuCaptureParameters")] + public GpuCaptureParameters GpuCaptureParametersField; + + [FieldOffset(0)] + public int other; + + public partial struct GpuCaptureParameters + { + public int a; + + public int b; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionFieldTypeNameClash/RemapTypeControlsClashingTypeName.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionFieldTypeNameClash/RemapTypeControlsClashingTypeName.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..cef074d3 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnionFieldTypeNameClash/RemapTypeControlsClashingTypeName.CSharp.Latest.Windows.cs @@ -0,0 +1,22 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + [StructLayout(LayoutKind.Explicit)] + public partial struct GpuCaptureUnion + { + [FieldOffset(0)] + [NativeTypeName("struct GpuCaptureParameters")] + public GpuCaptureParametersData GpuCaptureParameters; + + [FieldOffset(0)] + public int other; + + public partial struct GpuCaptureParametersData + { + public int a; + + public int b; + } + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnsafeFixedSizeBuffer/RemappedFixedSizeBufferLowersToPointerAndMarksClassUnsafe.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnsafeFixedSizeBuffer/RemappedFixedSizeBufferLowersToPointerAndMarksClassUnsafe.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..c5e55608 --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/UnsafeFixedSizeBuffer/RemappedFixedSizeBufferLowersToPointerAndMarksClassUnsafe.CSharp.Latest.Windows.cs @@ -0,0 +1,14 @@ +using System.Runtime.InteropServices; + +namespace ClangSharp.Test +{ + public static unsafe partial class Methods + { + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + public static extern void MyFunction([NativeTypeName("MyBuffer")] sbyte* value); + + [DllImport("ClangSharpPInvokeGenerator", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] + [return: NativeTypeName("MyBuffer")] + public static extern sbyte* MyOtherFunction(); + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/WithTypeField/OverridesFieldType.CSharp.Latest.Windows.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/WithTypeField/OverridesFieldType.CSharp.Latest.Windows.cs new file mode 100644 index 00000000..df70cd2b --- /dev/null +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/Baseline/Baselines/WithTypeField/OverridesFieldType.CSharp.Latest.Windows.cs @@ -0,0 +1,10 @@ +namespace ClangSharp.Test +{ + public partial struct Something + { + [NativeTypeName("int")] + public SomethingType type; + + public int other; + } +} diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/BooleanBitfieldTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/BooleanBitfieldTest.cs index 9f9561df..d33ca843 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/BooleanBitfieldTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/BooleanBitfieldTest.cs @@ -1,12 +1,15 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; -public sealed class BooleanBitfieldTest : PInvokeGeneratorTest +public sealed class BooleanBitfieldTest : StandaloneBaselineTest { + protected override string Area => "BooleanBitfield"; + // Regression test for https://github.com/dotnet/clangsharp/issues/508 // A `bool` bitfield previously generated invalid C# (a `bool` backing field plus // `bool & int` arithmetic and `(bool)` casts). It should use an integer backing store @@ -23,118 +26,12 @@ public sealed class BooleanBitfieldTest : PInvokeGeneratorTest [Test] public Task LatestTest() { - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public byte _bitfield1; - - [NativeTypeName(""bool : 1"")] - public bool a - { - readonly get - { - return (_bitfield1 & 0x1u) != 0; - } - - set - { - _bitfield1 = (byte)((_bitfield1 & ~0x1u) | ((value ? 1 : 0) & 0x1u)); - } - } - - [NativeTypeName(""bool : 1"")] - public bool b - { - readonly get - { - return ((_bitfield1 >> 1) & 0x1u) != 0; - } - - set - { - _bitfield1 = (byte)((_bitfield1 & ~(0x1u << 1)) | (((value ? 1 : 0) & 0x1u) << 1)); - } - } - - public int _bitfield2; - - [NativeTypeName(""int : 2"")] - public int c - { - readonly get - { - return (_bitfield2 << 30) >> 30; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x3) | (value & 0x3); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, expectedOutputContents); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(InputContents); } [Test] public Task CompatibleTest() { - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public byte _bitfield1; - - [NativeTypeName(""bool : 1"")] - public bool a - { - get - { - return (_bitfield1 & 0x1u) != 0; - } - - set - { - _bitfield1 = (byte)((_bitfield1 & ~0x1u) | ((value ? 1 : 0) & 0x1u)); - } - } - - [NativeTypeName(""bool : 1"")] - public bool b - { - get - { - return ((_bitfield1 >> 1) & 0x1u) != 0; - } - - set - { - _bitfield1 = (byte)((_bitfield1 & ~(0x1u << 1)) | (((value ? 1 : 0) & 0x1u) << 1)); - } - } - - public int _bitfield2; - - [NativeTypeName(""int : 2"")] - public int c - { - get - { - return (_bitfield2 << 30) >> 30; - } - - set - { - _bitfield2 = (_bitfield2 & ~0x3) | (value & 0x3); - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, expectedOutputContents); + return ValidateGeneratedCSharpCompatibleWindowsBaselineAsync(InputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/CTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/CTest.cs index caaa9b03..3ea828d1 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/CTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/CTest.cs @@ -3,12 +3,15 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; -public sealed class CTest : PInvokeGeneratorTest +public sealed class CTest : StandaloneBaselineTest { + protected override string Area => "C"; + [Test] public Task BasicTest() { @@ -22,49 +25,8 @@ typedef struct MyStruct { enum_t _field; } struct_t; "; - string expectedOutputContents; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum MyEnum - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } - - public partial struct MyStruct - { - [NativeTypeName(""enum_t"")] - public MyEnum _field; - } -} -"; - } - else - { - expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""unsigned int"")] - public enum MyEnum : uint - { - MyEnum_Value0, - MyEnum_Value1, - MyEnum_Value2, - } - - public partial struct MyStruct - { - [NativeTypeName(""enum_t"")] - public MyEnum _field; - } -} -"; - } - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestHostBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -84,60 +46,12 @@ enum { } field; }; "; - string expectedOutputContents; - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - [NativeTypeName(""__AnonymousEnum_ClangUnsavedFile_L8_C5"")] - public int field; - - public const int VALUEA = 0; - public const int VALUEB = 1; - public const int VALUEC = 2; - } - - public static partial class Methods - { - public const int VALUE1 = 0; - public const int VALUE2 = 1; - public const int VALUE3 = 2; - } -} -"; - } - else - { - expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - [NativeTypeName(""__AnonymousEnum_ClangUnsavedFile_L8_C5"")] - public uint field; - - public const uint VALUEA = 0; - public const uint VALUEB = 1; - public const uint VALUEC = 2; - } - - public static partial class Methods - { - public const uint VALUE1 = 0; - public const uint VALUE2 = 1; - public const uint VALUE3 = 2; - } -} -"; - } var diagnostics = new[] { new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L1_C1. Mapping values as constants in: Methods", "Line 1, Column 1 in ClangUnsavedFile.h"), new Diagnostic(DiagnosticLevel.Info, "Found anonymous enum: __AnonymousEnum_ClangUnsavedFile_L8_C5. Mapping values as constants in: Methods", "Line 8, Column 5 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, expectedDiagnostics: diagnostics, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestHostBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, expectedDiagnostics: diagnostics, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -169,53 +83,7 @@ typedef struct _MyStructWithAnonymousUnion } union1; } MyStructWithAnonymousUnion; "; - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public partial struct _MyStruct - { - public int _field; - } - - public unsafe partial struct _MyOtherStruct - { - [NativeTypeName(""MyStruct"")] - public _MyStruct _field1; - - [NativeTypeName(""MyStruct *"")] - public _MyStruct* _field2; - } - - public partial struct _MyStructWithAnonymousStruct - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L14_C5"")] - public __anonymousStructField1_e__Struct _anonymousStructField1; - - public partial struct __anonymousStructField1_e__Struct - { - public int _field; - } - } - - public partial struct _MyStructWithAnonymousUnion - { - [NativeTypeName(""__AnonymousRecord_ClangUnsavedFile_L21_C5"")] - public _union1_e__Union union1; - - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct _union1_e__Union - { - [FieldOffset(0)] - public int _field1; - - [FieldOffset(0)] - public int* _field2; - } - } -} -"; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -232,31 +100,7 @@ typedef union _MyOtherUnion MyUnion* _field2; } MyOtherUnion; "; - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct _MyUnion - { - [FieldOffset(0)] - public int _field; - } - - [StructLayout(LayoutKind.Explicit)] - public unsafe partial struct _MyOtherUnion - { - [FieldOffset(0)] - [NativeTypeName(""MyUnion"")] - public _MyUnion _field1; - - [FieldOffset(0)] - [NativeTypeName(""MyUnion *"")] - public _MyUnion* _field2; - } -} -"; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -265,20 +109,7 @@ public Task MacroTest() var inputContents = @"#define MyMacro1 5 #define MyMacro2 MyMacro1"; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - [NativeTypeName(""#define MyMacro1 5"")] - public const int MyMacro1 = 5; - - [NativeTypeName(""#define MyMacro2 MyMacro1"")] - public const int MyMacro2 = 5; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -333,98 +164,7 @@ public Task UnsignedIntBitshiftTest() // IntMin // ULongMax // Hexadecimal - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - [NativeTypeName(""const int"")] - public const int Signed = 1; - - [NativeTypeName(""const long"")] - public const int SignedLong = 1; - - [NativeTypeName(""const unsigned int"")] - public const uint Unsigned = 1; - - [NativeTypeName(""const int"")] - public const int ShiftSigned = 1 << Signed; - - [NativeTypeName(""const int"")] - public const int ShiftSignedLong = 1 << SignedLong; - - [NativeTypeName(""const int"")] - public const int ShiftUnsigned = 1 << (int)(Unsigned); - - [NativeTypeName(""const int"")] - public const int Char = 1 << (sbyte)('a'); - - [NativeTypeName(""const int"")] - public const int Byte = 1 << (sbyte)(1); - - [NativeTypeName(""const int"")] - public const int UByte = unchecked(1 << (byte)(1)); - - [NativeTypeName(""const int"")] - public const int CInt = 1 << 1; - - [NativeTypeName(""const int"")] - public const int CUint = 1 << 1; - - [NativeTypeName(""const int"")] - public const int Negative = 1 << -1; - - [NativeTypeName(""const int"")] - public const int OutOfRangePos = unchecked(1 << (int)(10000000000)); - - [NativeTypeName(""const int"")] - public const int OutOfRangeNeg = unchecked(1 << (int)(-10000000000)); - - [NativeTypeName(""const int"")] - public const int IntMax = 1 << 2147483647; - - [NativeTypeName(""const int"")] - public const int IntMin = unchecked(1 << -2147483648); - - [NativeTypeName(""const int"")] - public const int LongMax = unchecked(1 << (int)(9223372036854775807)); - - [NativeTypeName(""const int"")] - public const int LongMin = unchecked(1 << (int)(-9223372036854775808)); - - [NativeTypeName(""const int"")] - public const int ULongMax = 1 << -1; - - [NativeTypeName(""const int"")] - public const int Hexadecimal = 1 << 1; - - [NativeTypeName(""#define Left 1 << 1U"")] - public const int Left = 1 << 1; - - [NativeTypeName(""#define Right 1 >> 1U"")] - public const int Right = 1 >> 1; - - [NativeTypeName(""#define Int 1 << 1"")] - public const int Int = 1 << 1; - - [NativeTypeName(""#define Long 1 << 1L"")] - public const int Long = 1 << 1; - - [NativeTypeName(""#define LongLong 1 << 1LL"")] - public const int LongLong = 1 << 1; - - [NativeTypeName(""#define ULong 1 << 1UL"")] - public const int ULong = 1 << 1; - - [NativeTypeName(""#define ULongLong 1 << 1ULL"")] - public const int ULongLong = 1 << 1; - - [NativeTypeName(""#define Complex ((((unsigned int)(0)) << 29U) | (((unsigned int)(1)) << 22U) | (((unsigned int)(0)) << 12U) | ((unsigned int)(0)))"")] - public const uint Complex = ((((uint)(0)) << 29) | (((uint)(1)) << 22) | (((uint)(0)) << 12) | ((uint)(0))); - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } @@ -436,20 +176,7 @@ public Task UnsignedIntBitshiftTestUnix() const int ShiftSignedLong = 1 << SignedLong; "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - [NativeTypeName(""const long"")] - public const nint SignedLong = 1; - - [NativeTypeName(""const int"")] - public const int ShiftSignedLong = 1 << (int)(SignedLong); - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestUnixBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -470,62 +197,7 @@ typedef struct Bitfield { } Bitfield; "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct Bitfield - { - public byte _bitfield1; - - [NativeTypeName(""unsigned char : 8"")] - public byte bits1 - { - readonly get - { - return (byte)(_bitfield1 & 0xFFu); - } - - set - { - _bitfield1 = (byte)((_bitfield1 & ~0xFFu) | (value & 0xFFu)); - } - } - - public sbyte _bitfield2; - - [NativeTypeName(""char : 8"")] - public sbyte bits2 - { - readonly get - { - return (sbyte)((_bitfield2 << 0) >> 0); - } - - set - { - _bitfield2 = (sbyte)((_bitfield2 & ~0xFF) | (value & 0xFF)); - } - } - - public byte _bitfield3; - - [NativeTypeName(""unsigned char : 8"")] - public byte bits3 - { - readonly get - { - return (byte)(_bitfield3 & 0xFFu); - } - - set - { - _bitfield3 = (byte)((_bitfield3 & ~0xFFu) | (value & 0xFFu)); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestUnixBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -552,105 +224,7 @@ typedef struct UIntBitfield { } UIntBitfield; "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct IntBitfield - { - public int _bitfield; - - [NativeTypeName(""int : 8"")] - public int bits - { - readonly get - { - return (_bitfield << 24) >> 24; - } - - set - { - _bitfield = (_bitfield & ~0xFF) | (value & 0xFF); - } - } - - [NativeTypeName(""unsigned int : 8"")] - public uint bits2 - { - readonly get - { - return (uint)((_bitfield >> 8) & 0xFF); - } - - set - { - _bitfield = (_bitfield & ~(0xFF << 8)) | (int)((value & 0xFFu) << 8); - } - } - } - - public partial struct UIntBitfield - { - public uint _bitfield; - - [NativeTypeName(""unsigned int : 8"")] - public uint bits1 - { - readonly get - { - return _bitfield & 0xFFu; - } - - set - { - _bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu); - } - } - - [NativeTypeName(""int : 8"")] - public int bits2 - { - readonly get - { - return (int)(_bitfield << 16) >> 24; - } - - set - { - _bitfield = (_bitfield & ~(0xFFu << 8)) | (uint)((value & 0xFF) << 8); - } - } - - [NativeTypeName(""unsigned char : 8"")] - public byte bits3 - { - readonly get - { - return (byte)((_bitfield >> 16) & 0xFFu); - } - - set - { - _bitfield = (_bitfield & ~(0xFFu << 16)) | (uint)((value & 0xFFu) << 16); - } - } - - [NativeTypeName(""char : 8"")] - public sbyte bits4 - { - readonly get - { - return (sbyte)((sbyte)(_bitfield << 0) >> 24); - } - - set - { - _bitfield = (_bitfield & ~(0xFFu << 24)) | (uint)((value & 0xFF) << 24); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestUnixBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -668,50 +242,7 @@ typedef struct Bitfield { } Bitfield; "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""unsigned int"")] - public enum Flags : uint - { - Member = 0x7FFFFFFF, - } - - public partial struct Bitfield - { - public uint _bitfield; - - [NativeTypeName(""unsigned int : 8"")] - public uint bits - { - readonly get - { - return _bitfield & 0xFFu; - } - - set - { - _bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu); - } - } - - [NativeTypeName(""Flags : 8"")] - public Flags flags - { - readonly get - { - return (Flags)((_bitfield >> 8) & 0xFFu); - } - - set - { - _bitfield = (_bitfield & ~(0xFFu << 8)) | (((uint)(value) & 0xFFu) << 8); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestUnixBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -726,30 +257,7 @@ typedef struct Bitfield { } Bitfield; "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct Bitfield - { - public uint _bitfield; - - [NativeTypeName(""Number : 8"")] - public uint bits - { - readonly get - { - return _bitfield & 0xFFu; - } - - set - { - _bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestUnixBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -767,49 +275,7 @@ typedef struct Bitfield { } Bitfield; "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum Flags - { - Member = 0x7FFFFFFF, - } - - public partial struct Bitfield - { - public uint _bitfield; - - [NativeTypeName(""unsigned int : 8"")] - public uint bits - { - readonly get - { - return _bitfield & 0xFFu; - } - - set - { - _bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu); - } - } - - [NativeTypeName(""Flags : 8"")] - public Flags flags - { - readonly get - { - return (Flags)((_bitfield << 16) >> 24); - } - - set - { - _bitfield = (_bitfield & ~(0xFFu << 8)) | (((uint)(value) & 0xFF) << 8); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -828,50 +294,7 @@ typedef struct Bitfield { } Bitfield; "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""unsigned int"")] - public enum FlagBits : uint - { - Member = 0x7FFFFFFF, - } - - public partial struct Bitfield - { - public uint _bitfield; - - [NativeTypeName(""unsigned int : 8"")] - public uint bits - { - readonly get - { - return _bitfield & 0xFFu; - } - - set - { - _bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu); - } - } - - [NativeTypeName(""Flags : 8"")] - public uint flags - { - readonly get - { - return (_bitfield >> 8) & 0xFFu; - } - - set - { - _bitfield = (_bitfield & ~(0xFFu << 8)) | ((value & 0xFFu) << 8); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestUnixBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -890,50 +313,7 @@ typedef struct Bitfield { } Bitfield; "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - [NativeTypeName(""unsigned int"")] - public enum FlagBits : uint - { - Member = 0x7FFFFFFF, - } - - public partial struct Bitfield - { - public uint _bitfield; - - [NativeTypeName(""unsigned int : 8"")] - public uint bits - { - readonly get - { - return _bitfield & 0xFFu; - } - - set - { - _bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu); - } - } - - [NativeTypeName(""Flags : 8"")] - public FlagBits flags - { - readonly get - { - return (FlagBits)((_bitfield >> 8) & 0xFFu); - } - - set - { - _bitfield = (_bitfield & ~(0xFFu << 8)) | (((uint)(value) & 0xFFu) << 8); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, + return ValidateGeneratedCSharpLatestUnixBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard, @@ -956,44 +336,7 @@ typedef struct Bitfield { } Bitfield; "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct Bitfield - { - public uint _bitfield; - - [NativeTypeName(""unsigned int : 8"")] - public uint bits - { - readonly get - { - return _bitfield & 0xFFu; - } - - set - { - _bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu); - } - } - - [NativeTypeName(""Flags : 8"")] - public Flags flags - { - readonly get - { - return (Flags)((_bitfield >> 8) & 0xFFu); - } - - set - { - _bitfield = (_bitfield & ~(0xFFu << 8)) | (((uint)(value) & 0xFFu) << 8); - } - } - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, + return ValidateGeneratedCSharpLatestUnixBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard, @@ -1031,41 +374,7 @@ public Task CLongDefinesTestUnix() "; // We use "static readonly" instead of "const" because nint/nuint differ on 32/64-bit platforms - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - [NativeTypeName(""#define SIZE_MAX (18446744073709551615UL)"")] - public static readonly nuint SIZE_MAX = unchecked((nuint)(18446744073709551615U)); - - [NativeTypeName(""#define CL_IMPORT_MEMORY_WHOLE_ALLOCATION_ARM SIZE_MAX"")] - public static readonly nuint CL_IMPORT_MEMORY_WHOLE_ALLOCATION_ARM = unchecked((nuint)(18446744073709551615U)); - - [NativeTypeName(""#define LONG_MAX __LONG_MAX__"")] - public static readonly nint LONG_MAX = unchecked((nint)(9223372036854775807)); - - [NativeTypeName(""#define ULONG_MAX (__LONG_MAX__ *2UL+1UL)"")] - public static readonly nuint ULONG_MAX = unchecked((nuint)(9223372036854775807 * 2U + 1U)); - - [NativeTypeName(""#define CONST_IN_RANGE_S1 ((long)2147483647)"")] - public const nint CONST_IN_RANGE_S1 = ((nint)(2147483647)); - - [NativeTypeName(""#define CONST_IN_RANGE_U1 ((unsigned long)4294967295)"")] - public const nuint CONST_IN_RANGE_U1 = ((nuint)(4294967295)); - - [NativeTypeName(""#define READONLY_OUT_OF_RANGE_S1 ((long)4294967295)"")] - public static readonly nint READONLY_OUT_OF_RANGE_S1 = unchecked((nint)(4294967295)); - - [NativeTypeName(""#define READONLY_OUT_OF_RANGE_S2 ((long)4294967296)"")] - public static readonly nint READONLY_OUT_OF_RANGE_S2 = unchecked((nint)(4294967296)); - - [NativeTypeName(""#define READONLY_OUT_OF_RANGE_U1 ((unsigned long)4294967296)"")] - public static readonly nuint READONLY_OUT_OF_RANGE_U1 = unchecked((nuint)(4294967296)); - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestUnixBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -1100,32 +409,7 @@ bool SDL_size_add_check_overflow(size_t a, size_t b, size_t *ret) // The expected below currently does not represent the ideal behavior. // Ideally, the unchecked keywork is removed as it is unnecessary. // This issue is tracked here: https://github.com/dotnet/ClangSharp/issues/709 - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [return: NativeTypeName(""_Bool"")] - public static bool SDL_size_add_check_overflow([NativeTypeName(""size_t"")] nuint a, [NativeTypeName(""size_t"")] nuint b, [NativeTypeName(""size_t *"")] nuint* ret) - { - if (b > unchecked(18446744073709551615U) - a) - { - return (0) != 0; - } - - *ret = a + b; - return (1) != 0; - } - - [NativeTypeName(""#define true 1"")] - public const int @true = 1; - - [NativeTypeName(""#define false 0"")] - public const int @false = 0; - } -} -"; - - return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestUnixBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -1146,26 +430,7 @@ public Task CLongDefinesTestWindows() #define ULONG_MAX 0xffffffffUL "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static partial class Methods - { - [NativeTypeName(""#define SIZE_MAX 0xffffffffffffffffui64"")] - public const ulong SIZE_MAX = 0xffffffffffffffffUL; - - [NativeTypeName(""#define CL_IMPORT_MEMORY_WHOLE_ALLOCATION_ARM SIZE_MAX"")] - public const ulong CL_IMPORT_MEMORY_WHOLE_ALLOCATION_ARM = 0xffffffffffffffffUL; - - [NativeTypeName(""#define LONG_MAX 2147483647L"")] - public const int LONG_MAX = 2147483647; - - [NativeTypeName(""#define ULONG_MAX 0xffffffffUL"")] - public const uint ULONG_MAX = 0xffffffffU; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] @@ -1225,18 +490,6 @@ public Task VoidPointerArithmeticTest() } "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - public static void* MyFunction(void* buf, [NativeTypeName(""unsigned long long"")] ulong size) - { - return (byte*)buf + size; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/DeprecatedAdjacentStringTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/DeprecatedAdjacentStringTest.cs index 3b659878..0ffe1e16 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/DeprecatedAdjacentStringTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/DeprecatedAdjacentStringTest.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; @@ -11,8 +12,10 @@ namespace ClangSharp.UnitTests; /// C# string literal, otherwise the emitted [Obsolete(...)] attribute is invalid C#. /// [Platform("win")] -public sealed class DeprecatedAdjacentStringTest : PInvokeGeneratorTest +public sealed class DeprecatedAdjacentStringTest : StandaloneBaselineTest { + protected override string Area => "DeprecatedAdjacentString"; + [Test] public Task AdjacentStringLiteralsAreConcatenated() { @@ -21,20 +24,6 @@ public Task AdjacentStringLiteralsAreConcatenated() void MyFunction(); "; - var expectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [Obsolete(""Use Bar() or Baz() instead"")] - public static extern void MyFunction(); - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/FileScopedNamespaceTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/FileScopedNamespaceTest.cs index 71e77144..9c57fd35 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/FileScopedNamespaceTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/FileScopedNamespaceTest.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; @@ -12,26 +13,17 @@ namespace ClangSharp.UnitTests; /// must also not be indented as if they were nested inside a namespace block. /// [Platform("win")] -public sealed class FileScopedNamespaceTest : PInvokeGeneratorTest +public sealed class FileScopedNamespaceTest : StandaloneBaselineTest { + protected override string Area => "FileScopedNamespace"; + [Test] public Task MethodClassHasNoTrailingBrace() { var inputContents = @"extern ""C"" void MyFunction(); "; - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test; - -public static partial class Methods -{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces); } [Test] @@ -44,17 +36,7 @@ public Task StructHasNoTrailingBrace() }; "; - var expectedOutputContents = @"namespace ClangSharp.Test; - -public partial struct Point -{ - public int x; - - public int y; -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces); } [Test] @@ -75,30 +57,6 @@ enum Color extern ""C"" void MyFunction(); "; - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test; - -public partial struct Point -{ - public int x; - - public int y; -} - -public enum Color -{ - Red, - Green, -} - -public static partial class Methods -{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/FixedBufferIndexerOverloadsTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/FixedBufferIndexerOverloadsTest.cs index 4b6093f1..f3a7c846 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/FixedBufferIndexerOverloadsTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/FixedBufferIndexerOverloadsTest.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; @@ -13,8 +14,10 @@ namespace ClangSharp.UnitTests; /// int indexer is generated. /// [Platform("win")] -public sealed class FixedBufferIndexerOverloadsTest : PInvokeGeneratorTest +public sealed class FixedBufferIndexerOverloadsTest : StandaloneBaselineTest { + protected override string Area => "FixedBufferIndexerOverloads"; + [Test] public Task GeneratesOverloadsWhenEnabled() { @@ -29,73 +32,7 @@ struct MyOtherStruct }; "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public partial struct MyOtherStruct - { - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - { - public MyStruct e0; - public MyStruct e1; - public MyStruct e2; - - public unsafe ref MyStruct this[int index] - { - get - { - fixed (MyStruct* pThis = &e0) - { - return ref pThis[index]; - } - } - } - - public unsafe ref MyStruct this[uint index] - { - get - { - fixed (MyStruct* pThis = &e0) - { - return ref pThis[index]; - } - } - } - - public unsafe ref MyStruct this[nint index] - { - get - { - fixed (MyStruct* pThis = &e0) - { - return ref pThis[index]; - } - } - } - - public unsafe ref MyStruct this[nuint index] - { - get - { - fixed (MyStruct* pThis = &e0) - { - return ref pThis[index]; - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateFixedBufferIndexerOverloads); + return ValidateGeneratedCSharpCompatibleWindowsBaselineAsync(inputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateFixedBufferIndexerOverloads); } [Test] @@ -112,39 +49,6 @@ struct MyOtherStruct }; "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct MyStruct - { - public int value; - } - - public partial struct MyOtherStruct - { - [NativeTypeName(""MyStruct[3]"")] - public _c_e__FixedBuffer c; - - public partial struct _c_e__FixedBuffer - { - public MyStruct e0; - public MyStruct e1; - public MyStruct e2; - - public unsafe ref MyStruct this[int index] - { - get - { - fixed (MyStruct* pThis = &e0) - { - return ref pThis[index]; - } - } - } - } - } -} -"; - - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedCSharpCompatibleWindowsBaselineAsync(inputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/FunctionPointerRemapTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/FunctionPointerRemapTest.cs index 0bfa84aa..4a9eee25 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/FunctionPointerRemapTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/FunctionPointerRemapTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; @@ -13,8 +14,10 @@ namespace ClangSharp.UnitTests; /// invalid and produces CS8500). Remapping the typedef must not change that: only the delegate name /// is renamed while the field stays IntPtr and the containing struct stays non-unsafe. /// -public sealed class FunctionPointerRemapTest : PInvokeGeneratorTest +public sealed class FunctionPointerRemapTest : StandaloneBaselineTest { + protected override string Area => "FunctionPointerRemap"; + private const string InputContents = @"typedef void (ApiPFoo)(int); struct ApiCallbacks { ApiPFoo* Foo; }; "; @@ -25,31 +28,15 @@ struct ApiCallbacks { ApiPFoo* Foo; }; ["ApiPFoo"] = "PFoo" }; - private const string ExpectedOutputContents = @"using System; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - public delegate void PFoo(int param0); - - public partial struct Callbacks - { - [NativeTypeName(""ApiPFoo *"")] - public IntPtr Foo; - } -} -"; - [Test] public Task RemappedFnptrTypedefFieldStaysIntPtrWindows() { - return ValidateGeneratedCSharpCompatibleWindowsBindingsAsync(InputContents, ExpectedOutputContents, remappedNames: RemappedNames, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpCompatibleWindowsBaselineAsync(InputContents, remappedNames: RemappedNames, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] public Task RemappedFnptrTypedefFieldStaysIntPtrUnix() { - return ValidateGeneratedCSharpCompatibleUnixBindingsAsync(InputContents, ExpectedOutputContents, remappedNames: RemappedNames, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpCompatibleUnixBaselineAsync(InputContents, remappedNames: RemappedNames, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/GlobalStructInitializerTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/GlobalStructInitializerTest.cs index 4415f669..f830aa9d 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/GlobalStructInitializerTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/GlobalStructInitializerTest.cs @@ -1,12 +1,15 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; -public sealed class GlobalStructInitializerTest : PInvokeGeneratorTest +public sealed class GlobalStructInitializerTest : StandaloneBaselineTest { + protected override string Area => "GlobalStructInitializer"; + // Regression test for https://github.com/dotnet/clangsharp/issues/503 // A non-const global variable initialized with a struct initializer list was // missing its terminating semicolon, which corrupted the rest of the file. @@ -18,26 +21,6 @@ public Task NonConstGlobalTest() Point MyGlobalPoint = { .x = 10, .y = 20 }; "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct Point - { - public int x; - - public int y; - } - - public static partial class Methods - { - public static Point MyGlobalPoint = new Point - { - x = 10, - y = 20, - }; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/HelperTypesTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/HelperTypesTest.cs index 04a21397..e72fd327 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/HelperTypesTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/HelperTypesTest.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; @@ -16,8 +17,10 @@ namespace ClangSharp.UnitTests; /// class, rather than in the middle of the generated output. /// [Platform("win")] -public sealed class HelperTypesTest : PInvokeGeneratorTest +public sealed class HelperTypesTest : StandaloneBaselineTest { + protected override string Area => "HelperTypes"; + [Test] public Task HelperTypesEmittedInSharedNamespace() { @@ -28,59 +31,7 @@ public Task HelperTypesEmittedInSharedNamespace() }; "; - var expectedOutputContents = @"using System; -using System.Diagnostics; - -namespace ClangSharp.Test -{ - public unsafe partial struct SRC_DATA - { - [NativeTypeName(""const float *"")] - public float* data_in; - - [NativeTypeName(""long"")] - public int input_frames; - } - - /// Defines the type of a member as it was used in the native signature. - [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] - [Conditional(""DEBUG"")] - internal sealed partial class NativeTypeNameAttribute : Attribute - { - private readonly string _name; - - /// Initializes a new instance of the class. - /// The name of the type that was used in the native signature. - public NativeTypeNameAttribute(string name) - { - _name = name; - } - - /// Gets the name of the type that was used in the native signature. - public string Name => _name; - } - - /// Defines the annotation found in a native declaration. - [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] - [Conditional(""DEBUG"")] - internal sealed partial class NativeAnnotationAttribute : Attribute - { - private readonly string _annotation; - - /// Initializes a new instance of the class. - /// The annotation that was used in the native declaration. - public NativeAnnotationAttribute(string annotation) - { - _annotation = annotation; - } - - /// Gets the annotation that was used in the native declaration. - public string Annotation => _annotation; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateHelperTypes); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateHelperTypes); } [Test] @@ -93,58 +44,7 @@ public Task HelperTypesEmittedInSharedFileScopedNamespace() }; "; - var expectedOutputContents = @"using System; -using System.Diagnostics; - -namespace ClangSharp.Test; - -public unsafe partial struct SRC_DATA -{ - [NativeTypeName(""const float *"")] - public float* data_in; - - [NativeTypeName(""long"")] - public int input_frames; -} - -/// Defines the type of a member as it was used in the native signature. -[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] -[Conditional(""DEBUG"")] -internal sealed partial class NativeTypeNameAttribute : Attribute -{ - private readonly string _name; - - /// Initializes a new instance of the class. - /// The name of the type that was used in the native signature. - public NativeTypeNameAttribute(string name) - { - _name = name; - } - - /// Gets the name of the type that was used in the native signature. - public string Name => _name; -} - -/// Defines the annotation found in a native declaration. -[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] -[Conditional(""DEBUG"")] -internal sealed partial class NativeAnnotationAttribute : Attribute -{ - private readonly string _annotation; - - /// Initializes a new instance of the class. - /// The annotation that was used in the native declaration. - public NativeAnnotationAttribute(string annotation) - { - _annotation = annotation; - } - - /// Gets the annotation that was used in the native declaration. - public string Annotation => _annotation; -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateHelperTypes | PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateHelperTypes | PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces); } [Test] @@ -159,66 +59,7 @@ public Task HelperTypesEmittedAfterMethodClass() extern ""C"" void MyFunction(); "; - var expectedOutputContents = @"using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public unsafe partial struct SRC_DATA - { - [NativeTypeName(""const float *"")] - public float* data_in; - - [NativeTypeName(""long"")] - public int input_frames; - } - - public static partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); - } - - /// Defines the type of a member as it was used in the native signature. - [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] - [Conditional(""DEBUG"")] - internal sealed partial class NativeTypeNameAttribute : Attribute - { - private readonly string _name; - - /// Initializes a new instance of the class. - /// The name of the type that was used in the native signature. - public NativeTypeNameAttribute(string name) - { - _name = name; - } - - /// Gets the name of the type that was used in the native signature. - public string Name => _name; - } - - /// Defines the annotation found in a native declaration. - [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] - [Conditional(""DEBUG"")] - internal sealed partial class NativeAnnotationAttribute : Attribute - { - private readonly string _annotation; - - /// Initializes a new instance of the class. - /// The annotation that was used in the native declaration. - public NativeAnnotationAttribute(string annotation) - { - _annotation = annotation; - } - - /// Gets the annotation that was used in the native declaration. - public string Annotation => _annotation; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateHelperTypes); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateHelperTypes); } [Test] @@ -233,64 +74,6 @@ public Task HelperTypesEmittedAfterMethodClassFileScoped() extern ""C"" void MyFunction(); "; - var expectedOutputContents = @"using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace ClangSharp.Test; - -public unsafe partial struct SRC_DATA -{ - [NativeTypeName(""const float *"")] - public float* data_in; - - [NativeTypeName(""long"")] - public int input_frames; -} - -public static partial class Methods -{ - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction(); -} - -/// Defines the type of a member as it was used in the native signature. -[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] -[Conditional(""DEBUG"")] -internal sealed partial class NativeTypeNameAttribute : Attribute -{ - private readonly string _name; - - /// Initializes a new instance of the class. - /// The name of the type that was used in the native signature. - public NativeTypeNameAttribute(string name) - { - _name = name; - } - - /// Gets the name of the type that was used in the native signature. - public string Name => _name; -} - -/// Defines the annotation found in a native declaration. -[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] -[Conditional(""DEBUG"")] -internal sealed partial class NativeAnnotationAttribute : Attribute -{ - private readonly string _annotation; - - /// Initializes a new instance of the class. - /// The annotation that was used in the native declaration. - public NativeAnnotationAttribute(string annotation) - { - _annotation = annotation; - } - - /// Gets the annotation that was used in the native declaration. - public string Annotation => _annotation; -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateHelperTypes | PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateHelperTypes | PInvokeGeneratorConfigurationOptions.GenerateFileScopedNamespaces); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/MultipleBaseVtblSubobjectTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/MultipleBaseVtblSubobjectTest.cs index 08adf2c7..95ad87b7 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/MultipleBaseVtblSubobjectTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/MultipleBaseVtblSubobjectTest.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; @@ -16,8 +17,10 @@ namespace ClangSharp.UnitTests; /// secondary base's methods through the primary vtable. /// [Platform("win")] -public sealed class MultipleBaseVtblSubobjectTest : PInvokeGeneratorTest +public sealed class MultipleBaseVtblSubobjectTest : StandaloneBaselineTest { + protected override string Area => "MultipleBaseVtblSubobject"; + private const string InputContents = @"struct Foo { virtual ~Foo() = default; @@ -36,109 +39,13 @@ struct Baz : Foo, Bar [Test] public Task EmitsSecondaryBaseAsSubobject() { - var expectedOutputContents = @"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{ - public unsafe partial struct Foo - { - public void** lpVtbl; - - public void Dispose() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Foo*)Unsafe.AsPointer(ref this)); - } - } - - public unsafe partial struct Bar - { - public void** lpVtbl; - - public void Dispose() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Bar*)Unsafe.AsPointer(ref this)); - } - } - - [NativeTypeName(""struct Baz : Foo, Bar"")] - public unsafe partial struct Baz - { - public void** lpVtbl; - - public Bar Base2; - - public void Dispose() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Baz*)Unsafe.AsPointer(ref this)); - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, expectedOutputContents); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(InputContents); } [Test] public Task EmitsSecondaryBaseAsSubobjectWithExplicitVtbls() { - var expectedOutputContents = @"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{ - public unsafe partial struct Foo - { - public Vtbl* lpVtbl; - - public void Dispose() - { - lpVtbl->Dispose((Foo*)Unsafe.AsPointer(ref this)); - } - - public partial struct Vtbl - { - [NativeTypeName(""void () noexcept"")] - public delegate* unmanaged[Thiscall] Dispose; - } - } - - public unsafe partial struct Bar - { - public Vtbl* lpVtbl; - - public void Dispose() - { - lpVtbl->Dispose((Bar*)Unsafe.AsPointer(ref this)); - } - - public partial struct Vtbl - { - [NativeTypeName(""void () noexcept"")] - public delegate* unmanaged[Thiscall] Dispose; - } - } - - [NativeTypeName(""struct Baz : Foo, Bar"")] - public unsafe partial struct Baz - { - public Vtbl* lpVtbl; - - public Bar Base2; - - public void Dispose() - { - lpVtbl->Dispose((Baz*)Unsafe.AsPointer(ref this)); - } - - public partial struct Vtbl - { - [NativeTypeName(""void () noexcept"")] - public delegate* unmanaged[Thiscall] Dispose; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(InputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls); } // The non-unifying case: two bases contribute distinctly named virtual methods and the derived type @@ -164,140 +71,13 @@ struct Baz : Foo, Bar [Test] public Task DispatchesNonPrimaryBaseThroughSubobject() { - var expectedOutputContents = @"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{ - public unsafe partial struct Foo - { - public void** lpVtbl; - - public void FooMethod() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Foo*)Unsafe.AsPointer(ref this)); - } - } - - public unsafe partial struct Bar - { - public void** lpVtbl; - - public void BarMethod() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Bar*)Unsafe.AsPointer(ref this)); - } - } - - [NativeTypeName(""struct Baz : Foo, Bar"")] - public unsafe partial struct Baz - { - public void** lpVtbl; - - public Bar Base2; - - public void FooMethod() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Baz*)Unsafe.AsPointer(ref this)); - } - - public void BazMethod() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((Baz*)Unsafe.AsPointer(ref this)); - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(NonUnifyingInputContents, expectedOutputContents); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(NonUnifyingInputContents); } [Test] public Task InheritsPrimaryBaseMarkerInterfaceOnly() { - var expectedOutputContents = @"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{ - public unsafe partial struct Foo : Foo.Interface - { - public Vtbl* lpVtbl; - - public void FooMethod() - { - lpVtbl->FooMethod((Foo*)Unsafe.AsPointer(ref this)); - } - - public interface Interface - { - void FooMethod(); - } - - public partial struct Vtbl - where TSelf : unmanaged, Interface - { - [NativeTypeName(""void ()"")] - public delegate* unmanaged[Thiscall] FooMethod; - } - } - - public unsafe partial struct Bar : Bar.Interface - { - public Vtbl* lpVtbl; - - public void BarMethod() - { - lpVtbl->BarMethod((Bar*)Unsafe.AsPointer(ref this)); - } - - public interface Interface - { - void BarMethod(); - } - - public partial struct Vtbl - where TSelf : unmanaged, Interface - { - [NativeTypeName(""void ()"")] - public delegate* unmanaged[Thiscall] BarMethod; - } - } - - [NativeTypeName(""struct Baz : Foo, Bar"")] - public unsafe partial struct Baz : Baz.Interface - { - public Vtbl* lpVtbl; - - public Bar Base2; - - public void FooMethod() - { - lpVtbl->FooMethod((Baz*)Unsafe.AsPointer(ref this)); - } - - public void BazMethod() - { - lpVtbl->BazMethod((Baz*)Unsafe.AsPointer(ref this)); - } - - public interface Interface : Foo.Interface - { - void BazMethod(); - } - - public partial struct Vtbl - where TSelf : unmanaged, Interface - { - [NativeTypeName(""void ()"")] - public delegate* unmanaged[Thiscall] FooMethod; - - [NativeTypeName(""void ()"")] - public delegate* unmanaged[Thiscall] BazMethod; - } - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(NonUnifyingInputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(NonUnifyingInputContents, PInvokeGeneratorConfigurationOptions.GenerateExplicitVtbls | PInvokeGeneratorConfigurationOptions.GenerateMarkerInterfaces); } // A field-bearing polymorphic primary base cannot be flattened into the derived type's `lpVtbl` (the @@ -323,43 +103,7 @@ struct Baz : Foo, Bar [Test] public Task EmitsFieldBearingPrimaryBaseAsSubobject() { - var expectedOutputContents = @"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{ - public unsafe partial struct Foo - { - public void** lpVtbl; - - public int x; - - public void A() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Foo*)Unsafe.AsPointer(ref this)); - } - } - - public unsafe partial struct Bar - { - public void** lpVtbl; - - public void B() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((Bar*)Unsafe.AsPointer(ref this)); - } - } - - [NativeTypeName(""struct Baz : Foo, Bar"")] - public partial struct Baz - { - public Foo Base1; - - public Bar Base2; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(FieldBearingPrimaryInputContents, expectedOutputContents); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(FieldBearingPrimaryInputContents); } // Nested multiple inheritance: `C` derives from two polymorphic bases and `D` derives from `C`. @@ -392,80 +136,10 @@ struct D : C [Test] public Task FallsBackToFlattenedVtblForNestedMultipleInheritance() { - var expectedOutputContents = @"using System.Runtime.CompilerServices; - -namespace ClangSharp.Test -{ - public unsafe partial struct A - { - public void** lpVtbl; - - public void a() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((A*)Unsafe.AsPointer(ref this)); - } - } - - public unsafe partial struct B - { - public void** lpVtbl; - - public void b() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((B*)Unsafe.AsPointer(ref this)); - } - } - - [NativeTypeName(""struct C : A, B"")] - public unsafe partial struct C - { - public void** lpVtbl; - - public B Base2; - - public void a() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((C*)Unsafe.AsPointer(ref this)); - } - - public void c() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((C*)Unsafe.AsPointer(ref this)); - } - } - - [NativeTypeName(""struct D : C"")] - public unsafe partial struct D - { - public void** lpVtbl; - - public void a() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((D*)Unsafe.AsPointer(ref this)); - } - - public void b() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[0]))((D*)Unsafe.AsPointer(ref this)); - } - - public void c() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[1]))((D*)Unsafe.AsPointer(ref this)); - } - - public void d() - { - ((delegate* unmanaged[Thiscall])(lpVtbl[2]))((D*)Unsafe.AsPointer(ref this)); - } - } -} -"; - var expectedDiagnostics = new[] { new Diagnostic(DiagnosticLevel.Warning, "Unsupported cxx record declaration: 'nested multiple virtual bases'. Generated bindings for D may be incomplete.", "Line 16, Column 8 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(NestedMultipleInheritanceInputContents, expectedOutputContents, expectedDiagnostics: expectedDiagnostics); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(NestedMultipleInheritanceInputContents, expectedDiagnostics: expectedDiagnostics); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/NestedTypeReferenceTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/NestedTypeReferenceTest.cs index 10688ab5..18178287 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/NestedTypeReferenceTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/NestedTypeReferenceTest.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; @@ -11,8 +12,10 @@ namespace ClangSharp.UnitTests; /// (e.g. A::Inner -> A.Inner) so it resolves in the generated C#. /// [Platform("win")] -public sealed class NestedTypeReferenceTest : PInvokeGeneratorTest +public sealed class NestedTypeReferenceTest : StandaloneBaselineTest { + protected override string Area => "NestedTypeReference"; + [Test] public Task NestedTypeIsQualified() { @@ -30,25 +33,6 @@ struct B }; "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct A - { - - public partial struct Inner - { - public int value; - } - } - - public partial struct B - { - [NativeTypeName(""A::Inner"")] - public A.Inner inner; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/NullPtrMacroBindingTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/NullPtrMacroBindingTest.cs index fd53bd45..32e3f325 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/NullPtrMacroBindingTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/NullPtrMacroBindingTest.cs @@ -1,28 +1,21 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; /// Provides validation that a nullptr macro is generated as a void* constant rather than the invalid type name null. -public sealed class NullPtrMacroBindingTest : PInvokeGeneratorTest +public sealed class NullPtrMacroBindingTest : StandaloneBaselineTest { + protected override string Area => "NullPtrMacroBinding"; + [Test] public Task NullPtrMacroTest() { var inputContents = @"#define MY_NULL_HANDLE nullptr"; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [NativeTypeName(""#define MY_NULL_HANDLE nullptr"")] - public static readonly void* MY_NULL_HANDLE = null; - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/OptionsTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/OptionsTest.cs index f2c8bbaf..0d6b1567 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/OptionsTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/OptionsTest.cs @@ -2,12 +2,15 @@ using System.Collections.Generic; using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; -public sealed class OptionsTest : PInvokeGeneratorTest +public sealed class OptionsTest : StandaloneBaselineTest { + protected override string Area => "Options"; + [Test] public Task WithUsings() { @@ -18,31 +21,6 @@ struct StructB {}; struct StructC {}; } struct StructD {}; -"; - var expectedOutputContents = @"using ForStar; -using ForStructA1; -using ForStructA2; -using ForStructBWithDoubleColon; -using ForStructCWithDot; - -namespace ClangSharp.Test -{ - public partial struct StructA - { - } - - public partial struct StructB - { - } - - public partial struct StructC - { - } - - public partial struct StructD - { - } -} "; var withUsings = new Dictionary> { ["StructA"] = ["ForStructA1", "ForStructA2"], @@ -52,43 +30,19 @@ public partial struct StructD ["DoesNotExist"] = ["ErrorShouldNotBeInOutput"], }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withUsings: withUsings); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, withUsings: withUsings); } [Test] public Task WithAttributes() { var inputContents = @"struct StructA {}; struct StructB {}; struct StructC {}; struct StructD {};"; - var expectedOutputContents = -@"namespace ClangSharp.Test -{ - [A] - public partial struct StructA - { - } - - [B] - public partial struct StructB - { - } - - [Star] - public partial struct StructC - { - } - - [Star] - public partial struct StructD - { - } -} -"; var withAttributes = new Dictionary> { ["StructA"] = [@"A"], ["StructB"] = [@"B"], ["*"] = [@"Star"], }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withAttributes: withAttributes); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, withAttributes: withAttributes); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/SalFieldAttributeTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/SalFieldAttributeTest.cs index 7cf0d550..fbfd737b 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/SalFieldAttributeTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/SalFieldAttributeTest.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; @@ -13,8 +14,10 @@ namespace ClangSharp.UnitTests; /// emit the attribute the same way parameters do. /// [Platform("win")] -public sealed class SalFieldAttributeTest : PInvokeGeneratorTest +public sealed class SalFieldAttributeTest : StandaloneBaselineTest { + protected override string Area => "SalFieldAttribute"; + private const string InputContents = @"#define _Field_size_full_(x) __attribute__((annotate(""_Field_size_full_("" #x "")""))) struct MyStruct @@ -27,23 +30,10 @@ struct MyStruct [Test] public Task FieldSalAnnotationGeneratesCppAttributeList() { - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public unsafe partial struct MyStruct - { - public int count; - - [CppAttributeList(""_Field_size_full_(count)"")] - [NativeAnnotation(""_Field_size_full_(count)"")] - public int* data; - } -} -"; - var expectedDiagnostics = new[] { new Diagnostic(DiagnosticLevel.Warning, "Function like macro definition records are not supported: '_Field_size_full_'. Generated bindings may be incomplete.", "Line 1, Column 9 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, expectedOutputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateCppAttributes, expectedDiagnostics: expectedDiagnostics); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(InputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateCppAttributes, expectedDiagnostics: expectedDiagnostics); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/StripEnumMemberReferenceTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/StripEnumMemberReferenceTest.cs index 47b87ad8..9b30f1ec 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/StripEnumMemberReferenceTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/StripEnumMemberReferenceTest.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation and Contributors. All Rights Reserved. Licensed under the MIT License (MIT). See License.md in the repository root for more information. using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; @@ -12,8 +13,10 @@ namespace ClangSharp.UnitTests; /// the emitted code references undefined names. /// [Platform("win")] -public sealed class StripEnumMemberReferenceTest : PInvokeGeneratorTest +public sealed class StripEnumMemberReferenceTest : StandaloneBaselineTest { + protected override string Area => "StripEnumMemberReference"; + [Test] public Task SiblingReferencesAreStripped() { @@ -27,19 +30,6 @@ public Task SiblingReferencesAreStripped() } WGPUInstanceBackend; "; - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public enum WGPUInstanceBackend - { - Vulkan = 1 << 0, - GL = 1 << 1, - Metal = 1 << 2, - Primary = Vulkan | Metal, - Secondary = GL, - } -} -"; - - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, PInvokeGeneratorConfigurationOptions.StripEnumMemberTypeName); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, PInvokeGeneratorConfigurationOptions.StripEnumMemberTypeName); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/TransparentStructTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/TransparentStructTest.cs index b163e5a0..fcbf9354 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/TransparentStructTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/TransparentStructTest.cs @@ -2,160 +2,24 @@ using System.Collections.Generic; using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; -public sealed class TransparentStructTest : PInvokeGeneratorTest +public sealed class TransparentStructTest : StandaloneBaselineTest { + protected override string Area => "TransparentStruct"; + [Test] public Task BooleanKindGeneratesValidHelper() { var inputContents = @"typedef unsigned char MyBoolean;"; - var expectedOutputContents = @"using System; -using System.Diagnostics; - -namespace ClangSharp.Test -{ - /// Defines the type of a member as it was used in the native signature. - [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] - [Conditional(""DEBUG"")] - internal sealed partial class NativeTypeNameAttribute : Attribute - { - private readonly string _name; - - /// Initializes a new instance of the class. - /// The name of the type that was used in the native signature. - public NativeTypeNameAttribute(string name) - { - _name = name; - } - - /// Gets the name of the type that was used in the native signature. - public string Name => _name; - } - - /// Defines the annotation found in a native declaration. - [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true, Inherited = false)] - [Conditional(""DEBUG"")] - internal sealed partial class NativeAnnotationAttribute : Attribute - { - private readonly string _annotation; - - /// Initializes a new instance of the class. - /// The annotation that was used in the native declaration. - public NativeAnnotationAttribute(string annotation) - { - _annotation = annotation; - } - - /// Gets the annotation that was used in the native declaration. - public string Annotation => _annotation; - } - - public readonly partial struct MyBoolean : IComparable, IComparable, IEquatable, IFormattable - { - public readonly byte Value; - - public MyBoolean(byte value) - { - Value = value; - } - - public static MyBoolean FALSE => new MyBoolean(0); - - public static MyBoolean TRUE => new MyBoolean(1); - - public static bool operator ==(MyBoolean left, MyBoolean right) => left.Value == right.Value; - - public static bool operator !=(MyBoolean left, MyBoolean right) => left.Value != right.Value; - - public static bool operator <(MyBoolean left, MyBoolean right) => left.Value < right.Value; - - public static bool operator <=(MyBoolean left, MyBoolean right) => left.Value <= right.Value; - - public static bool operator >(MyBoolean left, MyBoolean right) => left.Value > right.Value; - - public static bool operator >=(MyBoolean left, MyBoolean right) => left.Value >= right.Value; - - public static implicit operator bool(MyBoolean value) => value.Value != 0; - - public static implicit operator MyBoolean(bool value) => new MyBoolean((byte)(value ? 1u : 0u)); - - public static bool operator false(MyBoolean value) => value.Value == 0; - - public static bool operator true(MyBoolean value) => value.Value != 0; - - public static implicit operator MyBoolean(byte value) => new MyBoolean(value); - - public static implicit operator byte(MyBoolean value) => value.Value; - - public static explicit operator MyBoolean(short value) => new MyBoolean(unchecked((byte)(value))); - - public static implicit operator short(MyBoolean value) => value.Value; - - public static explicit operator MyBoolean(int value) => new MyBoolean(unchecked((byte)(value))); - - public static implicit operator int(MyBoolean value) => value.Value; - - public static explicit operator MyBoolean(long value) => new MyBoolean(unchecked((byte)(value))); - - public static implicit operator long(MyBoolean value) => value.Value; - - public static explicit operator MyBoolean(nint value) => new MyBoolean(unchecked((byte)(value))); - - public static implicit operator nint(MyBoolean value) => value.Value; - - public static explicit operator MyBoolean(sbyte value) => new MyBoolean(unchecked((byte)(value))); - - public static explicit operator sbyte(MyBoolean value) => (sbyte)(value.Value); - - public static explicit operator MyBoolean(ushort value) => new MyBoolean(unchecked((byte)(value))); - - public static implicit operator ushort(MyBoolean value) => value.Value; - - public static explicit operator MyBoolean(uint value) => new MyBoolean(unchecked((byte)(value))); - - public static implicit operator uint(MyBoolean value) => value.Value; - - public static explicit operator MyBoolean(ulong value) => new MyBoolean(unchecked((byte)(value))); - - public static implicit operator ulong(MyBoolean value) => value.Value; - - public static explicit operator MyBoolean(nuint value) => new MyBoolean(unchecked((byte)(value))); - - public static implicit operator nuint(MyBoolean value) => value.Value; - - public int CompareTo(object? obj) - { - if (obj is MyBoolean other) - { - return CompareTo(other); - } - - return (obj is null) ? 1 : throw new ArgumentException(""obj is not an instance of MyBoolean.""); - } - - public int CompareTo(MyBoolean other) => Value.CompareTo(other.Value); - - public override bool Equals(object? obj) => (obj is MyBoolean other) && Equals(other); - - public bool Equals(MyBoolean other) => Value.Equals(other.Value); - - public override int GetHashCode() => Value.GetHashCode(); - - public override string ToString() => Value.ToString(); - - public string ToString(string? format, IFormatProvider? formatProvider) => Value.ToString(format, formatProvider); - } -} -"; - var withTransparentStructs = new Dictionary { ["MyBoolean"] = ("byte", PInvokeGeneratorTransparentStructKind.Boolean), }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateHelperTypes, withTransparentStructs: withTransparentStructs); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, additionalConfigOptions: PInvokeGeneratorConfigurationOptions.GenerateHelperTypes, withTransparentStructs: withTransparentStructs); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/UnionFieldTypeNameClashTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/UnionFieldTypeNameClashTest.cs index 2bd11f9e..e7dbc289 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/UnionFieldTypeNameClashTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/UnionFieldTypeNameClashTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; @@ -13,8 +14,10 @@ namespace ClangSharp.UnitTests; /// (with a warning) and can be controlled explicitly via --remap-type / --remap-field. /// [Platform("win")] -public sealed class UnionFieldTypeNameClashTest : PInvokeGeneratorTest +public sealed class UnionFieldTypeNameClashTest : StandaloneBaselineTest { + protected override string Area => "UnionFieldTypeNameClash"; + private const string InputContents = @"union GpuCaptureUnion { struct GpuCaptureParameters @@ -29,102 +32,30 @@ struct GpuCaptureParameters [Test] public Task AutoRenamesClashingTypeAndWarns() { - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct GpuCaptureUnion - { - [FieldOffset(0)] - [NativeTypeName(""struct GpuCaptureParameters"")] - public _GpuCaptureParameters_e__Struct GpuCaptureParameters; - - [FieldOffset(0)] - public int other; - - public partial struct _GpuCaptureParameters_e__Struct - { - public int a; - - public int b; - } - } -} -"; - var expectedDiagnostics = new[] { new Diagnostic(DiagnosticLevel.Warning, "Renamed nested type 'GpuCaptureParameters' to '_GpuCaptureParameters_e__Struct' to avoid a name clash with a field of the same name in 'GpuCaptureUnion'. Use '--remap-type GpuCaptureParameters=NewName' or '--remap-field GpuCaptureParameters=NewName' to control the naming explicitly.", "Line 3, Column 12 in ClangUnsavedFile.h") }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, expectedOutputContents, expectedDiagnostics: expectedDiagnostics, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(InputContents, expectedDiagnostics: expectedDiagnostics, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard); } [Test] public Task RemapTypeControlsClashingTypeName() { - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct GpuCaptureUnion - { - [FieldOffset(0)] - [NativeTypeName(""struct GpuCaptureParameters"")] - public GpuCaptureParametersData GpuCaptureParameters; - - [FieldOffset(0)] - public int other; - - public partial struct GpuCaptureParametersData - { - public int a; - - public int b; - } - } -} -"; - var remappedTypeNames = new Dictionary { ["GpuCaptureParameters"] = "GpuCaptureParametersData" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard, remappedTypeNames: remappedTypeNames); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(InputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard, remappedTypeNames: remappedTypeNames); } [Test] public Task RemapFieldControlsClashingFieldName() { - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - [StructLayout(LayoutKind.Explicit)] - public partial struct GpuCaptureUnion - { - [FieldOffset(0)] - [NativeTypeName(""struct GpuCaptureParameters"")] - public GpuCaptureParameters GpuCaptureParametersField; - - [FieldOffset(0)] - public int other; - - public partial struct GpuCaptureParameters - { - public int a; - - public int b; - } - } -} -"; - var remappedFieldNames = new Dictionary { ["GpuCaptureParameters"] = "GpuCaptureParametersField" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(InputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard, remappedFieldNames: remappedFieldNames); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(InputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard, remappedFieldNames: remappedFieldNames); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/UnsafeFixedSizeBufferTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/UnsafeFixedSizeBufferTest.cs index 8c05fd73..f695fb7c 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/UnsafeFixedSizeBufferTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/UnsafeFixedSizeBufferTest.cs @@ -2,12 +2,15 @@ using System.Collections.Generic; using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; -public sealed class UnsafeFixedSizeBufferTest : PInvokeGeneratorTest +public sealed class UnsafeFixedSizeBufferTest : StandaloneBaselineTest { + protected override string Area => "UnsafeFixedSizeBuffer"; + [Test] public Task RemappedFixedSizeBufferLowersToPointerAndMarksClassUnsafe() { @@ -16,26 +19,10 @@ public Task RemappedFixedSizeBufferLowersToPointerAndMarksClassUnsafe() extern ""C"" void MyFunction(MyBuffer value); extern ""C"" MyBuffer MyOtherFunction();"; - var expectedOutputContents = @"using System.Runtime.InteropServices; - -namespace ClangSharp.Test -{ - public static unsafe partial class Methods - { - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - public static extern void MyFunction([NativeTypeName(""MyBuffer"")] sbyte* value); - - [DllImport(""ClangSharpPInvokeGenerator"", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] - [return: NativeTypeName(""MyBuffer"")] - public static extern sbyte* MyOtherFunction(); - } -} -"; - var remappedNames = new Dictionary { ["MyBuffer"] = "sbyte[8]" }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, remappedNames: remappedNames); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, remappedNames: remappedNames); } } diff --git a/tests/ClangSharp.PInvokeGenerator.UnitTests/WithTypeFieldTest.cs b/tests/ClangSharp.PInvokeGenerator.UnitTests/WithTypeFieldTest.cs index 870b2ceb..9caf9735 100644 --- a/tests/ClangSharp.PInvokeGenerator.UnitTests/WithTypeFieldTest.cs +++ b/tests/ClangSharp.PInvokeGenerator.UnitTests/WithTypeFieldTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading.Tasks; +using ClangSharp.UnitTests.Baseline; using NUnit.Framework; namespace ClangSharp.UnitTests; @@ -13,8 +14,10 @@ namespace ClangSharp.UnitTests; /// preserved as a [NativeTypeName] attribute and unrelated fields are left untouched. /// [Platform("win")] -public sealed class WithTypeFieldTest : PInvokeGeneratorTest +public sealed class WithTypeFieldTest : StandaloneBaselineTest { + protected override string Area => "WithTypeField"; + [Test] public Task OverridesFieldType() { @@ -23,18 +26,6 @@ public Task OverridesFieldType() int type; int other; }; -"; - - var expectedOutputContents = @"namespace ClangSharp.Test -{ - public partial struct Something - { - [NativeTypeName(""int"")] - public SomethingType type; - - public int other; - } -} "; var withTypes = new Dictionary @@ -42,6 +33,6 @@ public partial struct Something ["Something.type"] = "SomethingType", }; - return ValidateGeneratedCSharpLatestWindowsBindingsAsync(inputContents, expectedOutputContents, withTypes: withTypes); + return ValidateGeneratedCSharpLatestWindowsBaselineAsync(inputContents, withTypes: withTypes); } }