Skip to content

Conversation

@reduckted
Copy link
Contributor

Relates to #312.

I've added an overload to PhysicalFile .TrySetAttributeAsync where you can pass in an enum value instead of a string for the property name. This allows unusual attribute names (such as {ItemType}, which maps to the build action) to be easily specified.

I've also changed the value parameter to be an object, which allows bool or enum values to be passed in rather than having the caller convert the value to a string.

Examples:

await file.TrySetAttributeAsync(PhysicalFileAttribute.BuildAction, "None");

await file.TrySetAttributeAsync(PhysicalFileAttribute.CopyToOutputDirectory, CopyToOutputDirectory.Always);

await file.TrySetAttributeAsync(PhysicalFileAttribute.Visible, false);

await file.TrySetAttributeAsync(PhysicalFileAttribute.CustomToolNamespace, "Test");

I got the list of attributes by getting the property descriptors from a C# file (using the same code that's used in TrySetAttributeAsync), and ignoring any that were read-only.

@madskristensen madskristensen merged commit 15e9fde into VsixCommunity:master Mar 29, 2022
@madskristensen
Copy link
Contributor

That is absolutely awesome. Thank you so much!!

@reduckted reduckted deleted the feature/known-physiscal-file-attributes branch March 29, 2022 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants