Skip to content

Add support for @(AssemblyMetadata) items that turn into assembly attributes#3440

Merged
dsplaisted merged 2 commits into
dotnet:masterfrom
kzu:patch-2
Jan 16, 2020
Merged

Add support for @(AssemblyMetadata) items that turn into assembly attributes#3440
dsplaisted merged 2 commits into
dotnet:masterfrom
kzu:patch-2

Conversation

@kzu

@kzu kzu commented Jul 19, 2019

Copy link
Copy Markdown
Contributor

Given that AssemblyMetadataAttribute is such a common assembly-level attribute, this adds support
for specifying it directly via simple items, such as:

    <AssemblyMetadata Include="Foo" Value="Bar" />
    <AssemblyMetadata Include="Bar" Value="Baz" />

This also avoids having to learn the _Parameter1 and _Parameter2 syntax in AssemblyAttribute elements,
and is more similar to the way other higher-level properties like AssemblyTitle or Product are also
turned into assembly attributes.

Partially fixes #3166

The feature can be disabled by setting $(GenerateAssemblyMetadataAttributes) to false.

@peterhuene peterhuene added this to the 3.0.1xx milestone Jul 19, 2019
@peterhuene peterhuene requested a review from a team July 19, 2019 17:48
@peterhuene

Copy link
Copy Markdown
Contributor

Hi @kzu. This looks good.

Could you add some test coverage to this PR?

@kzu

kzu commented Jul 25, 2019

Copy link
Copy Markdown
Contributor Author

Could you point me to the place where existing tests for the other AssemblyAttribute items are so I can add to those? Thanks!

@peterhuene

Copy link
Copy Markdown
Contributor

@kzu here is a test that is setting the individual properties that cause additional AssemblyAttribute items to be defined.

We should probably add a test to this file to cover setting AssemblyMetadata items in the test project file and reflecting on the output assembly to ensure the attributes were set.

…ributes

Given that `AssemblyMetadataAttribute` is such a common assembly-level attribute, this adds support
for specifying it directly via simple items, such as:

```
    <AssemblyMetadata Include="Foo" Value="Bar" />
    <AssemblyMetadata Include="Bar" Value="Baz" />
```

This also avoids having to learn the `_Parameter1` and `_Parameter2` syntax in `AssemblyAttribute` elements,
and is more similar to the way other higher-level properties like `AssemblyTitle` or `Product` are also
turned into assembly attributes.

Partially fixes #3166

The feature can be disabled by setting `$(GenerateAssemblyMetadataAttributes)` to `false`.
@kzu

kzu commented Sep 15, 2019

Copy link
Copy Markdown
Contributor Author

@peterhuene added two tests to verify both new scenarios supported.

Thanks!

kzu added a commit to kzu/visualstudio-docs that referenced this pull request Sep 15, 2019
@kzu

kzu commented Sep 15, 2019

Copy link
Copy Markdown
Contributor Author

Added the corresponding docs PR too.

@nguerrera nguerrera modified the milestones: 3.0.1xx, 5.0.1xx Oct 28, 2019
@kzu

kzu commented Jan 14, 2020

Copy link
Copy Markdown
Contributor Author

All green now :shipit:

@dsplaisted

Copy link
Copy Markdown
Member

@sfoslund Would you like to review this PR?

@sfoslund sfoslund left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

new XAttribute("Value", "MetadataValue"))));
});

new RestoreCommand(Log, testAsset.TestRoot).Execute().Should().Pass();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I believe it's not usually necessary to explicitly restore before building anymore, is that correct @dsplaisted

buildCommand.Execute().Should().Pass();

var assemblyPath = Path.Combine(buildCommand.GetOutputDirectory("netstandard2.0").FullName, "HelloWorld.dll");
var info = AssemblyInfo.Get(assemblyPath);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: variable never used

@dsplaisted dsplaisted merged commit 94d4bc3 into dotnet:master Jan 16, 2020
@kzu kzu deleted the patch-2 branch January 18, 2020 23:30
dsplaisted pushed a commit to dsplaisted/sdk that referenced this pull request Feb 19, 2020
* Update dependencies from https://github.com/aspnet/AspNetCore build 20191102.3

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19552.3

* Update dependencies from https://github.com/aspnet/AspNetCore build 20191103.1

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19553.1

* Update dependencies from https://github.com/aspnet/AspNetCore build 20191104.1

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19554.1
dsplaisted pushed a commit to dsplaisted/sdk that referenced this pull request Feb 19, 2020
* master: (27 commits)
  Add DOTNET_ROOT to tests and fix dogfood script
  Remove duplicated key
  Installation script update (dotnet#13030)
  Use scanelf over ldconfig on musl-libc distros (dotnet#12642)
  Allow list more properties (dotnet#3459)
  Update dependencies from https://github.com/mono/linker build 20191106.1 (dotnet#3476)
  [master] Update dependencies from aspnet/websdk (dotnet#3466)
  Update dependencies from https://github.com/aspnet/AspNetCore build 20191105.3 (dotnet#3473)
  Update dependencies from https://github.com/dotnet/windowsdesktop build 20191105.1 (dotnet#3469)
  Update dependencies from https://github.com/dotnet/arcade build 20191104.3 (dotnet#3465)
  Update dependencies from https://github.com/aspnet/websdk build 20191103.2 (dotnet#3454)
  [master] Update dependencies from dotnet/arcade (dotnet#3416)
  Update dependencies from https://github.com/aspnet/AspNetCore build 20191104.3 (dotnet#3458)
  Update dependencies from https://github.com/dotnet/templating build 20191104.1 (dotnet#3457)
  [master] Update dependencies from Microsoft/msbuild (dotnet#3423)
  [master] Update dependencies from aspnet/AspNetCore (dotnet#3440)
  Update dependencies from https://github.com/dotnet/windowsdesktop build 20191104.2 (dotnet#3455)
  [master] Update dependencies from dotnet/core-setup (dotnet#3445)
  Update dependencies from https://github.com/dotnet/windowsdesktop build 20191102.6 (dotnet#3446)
  Update dependencies from https://github.com/aspnet/websdk build 20191102.2 (#3444)
  ...
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.

GenerateAssemblyInfo support for InternalsVisibleToAttribute and AssemblyMetadataAttribute

5 participants