Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ThisAssemblyVisibility for public and static readonly constants #400

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

kzu
Copy link
Member

@kzu kzu commented Sep 27, 2024

Setting the ThisAssembly class to public should be somewhat rare, but might be desirable in some cases. When the class is made public, there's a surprising "bug" in that updating the assembly providing the ThisAssembly class will not cause another assembly consuming its values to reflect the changes. This is because the compiler will efectively inline the constants, so effectively every call site has a copy of the value.

This is somewhat unintuitive, but it's perfectly sensible when the use is for internal purposes.

The new ThisAssemblyVisibility=public property allows both setting the generated class visibility to and switching (for constants) to static properties.

For ThisAssembly.Strings and ThisAssembly.Resources, only the class visibility is changed.

Fixes #64

@kzu kzu added the enhancement New feature or request label Sep 27, 2024
@kzu kzu enabled auto-merge (rebase) September 27, 2024 03:56
@devlooped-bot
Copy link
Member

devlooped-bot commented Sep 27, 2024

29 passed 29 passed

🧪 Details on Microsoft Windows 10.0.20348

✅ ThisAssemblyTests.ScribanTests.CanRenderModel
✅ ThisAssemblyTests.Tests.CanReadResourceFile
✅ ThisAssemblyTests.Tests.CanUseByteResource
✅ ThisAssemblyTests.Tests.CanUseConstants
✅ ThisAssemblyTests.Tests.CanUseFileConstantInvalidIdentifier
✅ ThisAssemblyTests.Tests.CanUseFileConstantLinkedFile
✅ ThisAssemblyTests.Tests.CanUseFileConstants
✅ ThisAssemblyTests.Tests.CanUseFileInvalidCharacters
✅ ThisAssemblyTests.Tests.CanUseGitBranchConstants
✅ ThisAssemblyTests.Tests.CanUseGitConstants
✅ ThisAssemblyTests.Tests.CanUseHierarchicalMetadata
✅ ThisAssemblyTests.Tests.CanUseInfo
✅ ThisAssemblyTests.Tests.CanUseInfoDescription
✅ ThisAssemblyTests.Tests.CanUseMetadata
✅ ThisAssemblyTests.Tests.CanUseMultilineProjectProperty
✅ ThisAssemblyTests.Tests.CanUseProjectProperty
✅ ThisAssemblyTests.Tests.CanUseSameNameDifferentExtensions
✅ ThisAssemblyTests.Tests.CanUseSemicolonsInConstant
✅ ThisAssemblyTests.Tests.CanUseStringResource
✅ ThisAssemblyTests.Tests.CanUseStringsIndexedArguments
✅ ThisAssemblyTests.Tests.CanUseStringsIndexedFormattedArguments
✅ ThisAssemblyTests.Tests.CanUseStringsNamedArguments
✅ ThisAssemblyTests.Tests.CanUseStringsNamedFormattedArguments
✅ ThisAssemblyTests.Tests.CanUseTextResource
✅ ThisAssemblyTests.Tests.CanUseTypedBoolConstant
✅ ThisAssemblyTests.Tests.CanUseTypedDoubleConstant
✅ ThisAssemblyTests.Tests.CanUseTypedInt64Constant
✅ ThisAssemblyTests.Tests.CanUseTypedIntConstant
✅ ThisAssemblyTests.Tests.CanUseTypedLongConstant

from dotnet-retest v0.6.3 on .NET 8.0.8 with 💜

@kzu kzu disabled auto-merge September 27, 2024 03:57
Setting the `ThisAssembly` class to public should be somewhat rare, but might be desirable in some cases. When the class is made public, there's a surprising "bug" in that updating the assembly providing the `ThisAssembly` class will *not* cause another assembly consuming its values to reflect the changes. This is because the compiler will efectively inline the constants, so effectively every call site has a copy of the value.

This is somewhat unintuitive, but it's perfectly sensible when the use is for internal purposes.

The new ThisAssemblyVisibility=public property allows both setting the generated class visibility to public and switching (for constants) to static properties.

For ThisAssembly.Strings and ThisAssembly.Resources, only the class visibility is changed.

Fixes #64
@kzu kzu enabled auto-merge (rebase) September 27, 2024 03:57
@kzu kzu merged commit 0128f80 into main Sep 27, 2024
11 checks passed
@kzu kzu deleted the dev/public branch September 27, 2024 04:01
@kzu kzu changed the title Allow setting visibility and switching to static readonly props Add support for ThisAssemblyVisibility for public and static readonly constants Sep 27, 2024
@devlooped devlooped locked and limited conversation to collaborators Oct 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow switching to static readonly properties instead of constants
2 participants