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

Change in GeneralAppInfo.cs causes build failure #2592

Open
tecxx opened this issue May 4, 2024 · 2 comments
Open

Change in GeneralAppInfo.cs causes build failure #2592

tecxx opened this issue May 4, 2024 · 2 comments

Comments

@tecxx
Copy link
Contributor

tecxx commented May 4, 2024

the recent commit 83f3846 has a change in mRemoteNG/App/Info/GeneralAppInfo.cs

line 21 is now readonly
public static readonly string ApplicationVersion = Application.ProductVersion;

this causes UpdaterTests.cs to fail building
image

@xRushG
Copy link
Contributor

xRushG commented May 6, 2024

I can confirm the error you encountered. It arises due to the limitations imposed by the nature of static classes and readonly fields. Since GeneralAppInfo is a static class with a readonly field ApplicationVersion, direct modification for testing purposes is not feasible within the current setup. However, one workaround is to introduce a protected static method within GeneralAppInfo that allows setting the application version internally, and then changing ApplicationVersion to have a private setter.

public static string ApplicationVersion { get; private set; } = Application.ProductVersion;

public static void SetApplicationVersion(string version)
{
    ApplicationVersion = version;
}

You can then use SetApplicationVersion in NUnit tests. However, it's worth noting that this approach may not provide significant benefits, as there are no checks implemented in the setter method. I dont know.

I've encountered additional issues following the recent changes:
1)
image

To resolve this, I need to change the project settings' langVersion from 'latest' to 'preview'. However, I'm not sure if this is the best approach. What do you think?

image

Perhaps this is a typo:

string detailsString = string.Join("; ", [.. details]);

The corrected version would be:

string detailsString = string.Join("; ",  details);

Can anyone else confirm this?

Consider temporarily removing the read only flag for 'Application Version' in your local repository without committing the change. If you encounter the other two bugs, address them similar.

@xRushG
Copy link
Contributor

xRushG commented May 24, 2024

Oh, forgot what i say....

Update Visual Studio to the latest version, and everything will be fine:

Microsoft Visual Studio Community 2022 (64-bit) - Current
Version 17.10.0

Only the readonly flag needs to be removed:

public static readonly string ApplicationVersion = Application.ProductVersion;

I'll take care of it.

xRushG added a commit to xRushG/mRemoteNG that referenced this issue May 29, 2024
…ing set in Unit Tests. Not needed for tests.
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

No branches or pull requests

2 participants