question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Where do builds set the AssemblyCompanyAttribute attribute for assemblies?

See original GitHub issue

Discussed in https://github.com/dotnet/source-build/discussions/3134

<div type='discussions-op-text'>

Originally posted by jcolebrand November 29, 2022 Where do builds set the AssemblyCompanyAttribute attribute for assemblies?

Apologies if this is the wrong place, feel free to redirect me to a better place to ask, but seems like the source-build team knows these things better than anyone, if I had to guess.

We are looking to build some tooling around assembly scanning and wanted to exclude the Microsoft assemblies from our internal assemblies (not excluding everyone’s assemblies, just the ones owned by the Microsoft teams) and wanted to know if there was a likelihood that the AssemblyCompanyAttribute attribute may change in the future. With quite a few thousand (mostly tests and handling code) results in github seearch, and knowing that it is usually just AssemblyCompany in expected files, I’m not sure how to narrow it down to see where it might get injected into a build pipeline.

“But Cole, why would it ever change from Microsoft” excellent question. While I can ponder a few ideas, such as a Community Foundation type naming structure, I don’t know exactly, but figured if I can find who owns that, they can give me a better indication of if it might ever change.

FWIW this is the code my coworker wrote today:

        private static bool IsMicrosoftAssembly(AssemblyDefinition assembly)
        {
            if (assembly.HasCustomAttributes)
            {
                var assemblyCompany = assembly.CustomAttributes.FirstOrDefault(a => a.AttributeType.FullName == "System.Reflection.AssemblyCompanyAttribute");

                return ((assemblyCompany != null)
                    && assemblyCompany.ConstructorArguments.Any(arg => arg.Value?.ToString().StartsWith("Microsoft") == true));
            }

            return false;
        }

I’m sure you can see how that would potentially be a problem, especially if we don’t understand the nuances, etc. Is it brittle? Almost certainly.

I would also accept “look, don’t do that, do this instead” but better to learn how to fish with seeing the entirety of the ecosystem than to ask highly specific questions, because I would like to learn how to fish.

If it were me setting this up, I would have that as a variable in a pipeline and not hard-coded in a script, which are dynamic, and so I expect it is here as well.

Cheers!</div>

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jcolebrandcommented, Dec 2, 2022

@riarenas I agree, but sometimes people have floated ideas in the past and someone knows a thing or two, ya know?

@crummel I agree that’s annoying.

Thanks all for the answers. As always, y’all are amazing and I am a very grateful pipeline consuming dev. I appreciate all the work y’all and your teams put into keeping this thing going strong!

0reactions
michellemcdanielcommented, Jan 12, 2023

Closing this as it seems the questions were answered

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set assembly attributes
Assembly attributes are values that provide information about an assembly. They're usually set in an AssemblyInfo.cs file.
Read more >
c# - Custom Assembly Attributes
I would like to know if I can define custom assembly attributes. Existing attributes are defined in the following way:
Read more >
Duplicate 'System.Reflection.AssemblyCompanyAttribute' ...
Sure. We auto-generate our own AssemblyInfo.common.cs file that we link into each project. This file defines all the normal assembly level ...
Read more >
Duplicate 'System.Reflection.AssemblyCompanyAttribute' ...
Searching the project each of these attributes only exists only in the AssemblyInfo.cs file found under properties.
Read more >
.NET Assembly-Level Attributes - YouTube
Assembly -level attributes don't relate to any constructs in code, so where should you put them? As so often, the answer is different...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found