C1Schedule .643: warning "CA1416: ... is only supported on: 'windows' 6.1"

Posted by: wknauf on 27 March 2024, 8:51 pm EST

    • Post Options:
    • Link

    Posted 27 March 2024, 8:51 pm EST

    Hi C1,

    after updating C1Schedule to .643, this warning is reported in our projects referencing C1Schedule:

    warning CA1416: This call site is reachable on: ‘windows’ all versions. ‘…’ is only supported on: ‘windows’ 6.1 and later. (https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

    I could reproduce it with attached sample:

    ScheduleTest.zip

    With .636 it works, which makes me think that it is related to C1 somehow ;-).

    We switch off this warning in “AssemblyInfo.cs” previously:

    [assembly: System.Runtime.Versioning.SupportedOSPlatform("windows")]

    But this does not work with the newest version.

    It seems to happen only because we use “global.json” to force the SDK version to 6.0:

    {
      "sdk": {
        "version": "6.0.0",
        "rollForward": "latestFeature"
      }
    }
    

    If I enter “7.0.0” in this file, the warning disappears also. So it might also be a bug in the SDK. But I want to stay with the SDK matching our target framework version - don’t know whether it could cause issues to switch the SDK version to 8.0.0.

    I found two workarounds:

    Workaround 1:

    Define the “SupportedOSPlatform” like this:

    [assembly: System.Runtime.Versioning.SupportedOSPlatform("windows6.1")]

    Workaround 2:

    Suppress the warning:

    [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility")]

    Do you have any idea on this? Is it related to some change in version .643?

    Best regards

    Wolfgang

    Note: I will be on vacation for the next three weeks, but will check my mails occasionally, so replies might be delayed.

  • Posted 31 March 2024, 11:14 pm EST

    Hello Wolfgang,

    Thank you for providing details and a sample project.

    We checked the sample provided by you, and the warning was not observed due to C1Schedule or any specific version of C1Schedule. The warning is observed due to the following line of code in your sample:

    Font f = SystemFonts.MessageBoxFont;

    Please refer to the attached GIF showing how the warning goes away by removing the SystemFonts line. (see SystemFonts_Warning.zip)

    If you meant something different, could you please provide a video showing the exact steps you followed to reproduce the issue?

    Regards,

    Uttkarsh.

  • Posted 4 April 2024, 5:46 am EST

    Hi Uttkarsh,

    the usage of “SystemFonts.MessageBoxFont” was only a sample. The warning seems to be triggered by a lot of code calls - we had several hundred warnings in our real world application after updating to recent C1Schedule version.

    Before .643, we used the assembly attribute “SupportedOSPlatform” to switch it off - this seems to be the suggested way to handle this.

    But with .643, this does not work any more, so my question is whether you have any idea why it is happening now? There must have been a change in the C1Schedule dll.

    Change the C1 version to .636 and the warning will not be reported any more when “SupportedOSPlatform” is set.

    Anyway, this seems to be fixed by switching to .NET8 in the future, and I found other workarounds as long as we stay with .NET6. So this is not a high priority issue, but I wanted to bring it to your attention.

    Best regards

    Wolfgang

  • Posted 4 April 2024, 11:29 pm EST

    Hello Wolfgang,

    Thank you for explaining the behavior further. We appreciate your efforts.

    C1.Win.Schedule (.636) uses two MS libraries as dependencies:

    *Microsoft.Win32.SystemEvents (v6.0.0)

    *System.Drawing.Common (v6.0.0)

    However, the latest version (.643) uses the 8.0.0 version of both of these MS libraries, which supports ‘windows 6.1’ and later and is the cause of this warning. Rest assured, you can keep using the latest version without any issues.

    Please refer to the attached images for the transitive dependencies. (see MSdependencies.zip)

    Regards,

    Uttkarsh.

  • Posted 7 April 2024, 1:54 am EST

    Hi Uttkarsh,

    thanks for the clarification, I didn’t dig deep enough ;-). So I will add the workarounds to our application in case we update to .643 or later (currently blocked by other issues).

    Best regards

    Wolfgang

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels