-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1177 from microsoft/improveInputErrorReporting
Improve input error reporting
- Loading branch information
Showing
4 changed files
with
92 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
test/Microsoft.Windows.CsWin32.Tests/GeneratorConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
internal record GeneratorConfiguration | ||
{ | ||
internal static GeneratorConfiguration Default { get; } = new(); | ||
|
||
internal ImmutableArray<string> InputMetadataPaths { get; init; } = CollectAssemblyMetadata("ProjectionMetadataWinmd"); | ||
|
||
internal ImmutableArray<string> InputDocPaths { get; init; } = CollectAssemblyMetadata("ProjectionDocs"); | ||
|
||
internal string ToGlobalConfigString() | ||
{ | ||
StringBuilder globalConfigBuilder = new(); | ||
globalConfigBuilder.AppendLine("is_global = true"); | ||
globalConfigBuilder.AppendLine(); | ||
AddPathsProperty("CsWin32InputMetadataPaths", this.InputMetadataPaths); | ||
AddPathsProperty("CsWin32InputDocPaths", this.InputDocPaths); | ||
|
||
return globalConfigBuilder.ToString(); | ||
|
||
void AddPathsProperty(string name, ImmutableArray<string> paths) | ||
{ | ||
if (!paths.IsEmpty) | ||
{ | ||
globalConfigBuilder.AppendLine($"build_property.{name} = {string.Join("|", paths)}"); | ||
} | ||
} | ||
} | ||
|
||
private static ImmutableArray<string> CollectAssemblyMetadata(string name) => [.. typeof(GeneratorTests).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>().Where(metadata => metadata.Key == name && metadata.Value is not null).Select(metadata => metadata.Value)]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters