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

When there is a commented AssemblyVersion in the AssemblyInfo file, it changes that one, but doesn't change the uncommented one #10

Closed
jkwinder opened this issue May 3, 2024 · 3 comments · Fixed by #11
Labels
enhancement New feature or request

Comments

@jkwinder
Copy link

jkwinder commented May 3, 2024

This is the result after I've run the version updated on an AssemblyInfo.cs file showing that the replacement only occurs on the first occurence in the file even if the line that it changes is commented, and subsequent uncommented AssemblyVersions are left unmodified... 
// [assembly: AssemblyVersion("24.8.2.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("24.8.2.0")]

@vers-one
Copy link
Owner

vers-one commented May 4, 2024

Unfortunately, there is not much that can be done to skip these occurrences. I could add an extra check to exclude the lines that have two slashes at the beginning, but that will not affect multi-line comments or string literals like

string attribute = """[assembly: AssemblyVersion("1.0.0.0")]""";

Adding a full C# syntax parser into a simple GitHub action also doesn't feel like a good idea.

I will add an error message for the case when there are two or more matching occurrences found in a single file.

@jkwinder
Copy link
Author

jkwinder commented May 4, 2024

Thanks for adding the error message! I like the idea of checking to exclude lines that begin with the // comment. I realize that doesn't catch the multi-line, but would certainly solve the bulk of cases and especially those comments that are typical in an AssemblyInfo.cs

@vers-one vers-one linked a pull request May 8, 2024 that will close this issue
@vers-one
Copy link
Owner

vers-one commented May 8, 2024

Implemented in version 1.6.

Apart from the new error message for duplicate attributes, the action will now require the attributes to appear at the beginning of the line (after trimming whitespace characters). This will allow it to skip commented lines, e.g.

// [assembly: AssemblyVersion("1.2.3")]

but it will also skip attributes when they appear on the same line after another attribute:

[assembly: AssemblyVersion("1.2.3")] [assembly: AssemblyFileVersion("1.2.3")]

(only the first attribute will be processed).

I think this is a reasonable compromise because the first case is much more common than the second one.

@vers-one vers-one added the enhancement New feature or request label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants