Skip to content

Conversation

mycroes
Copy link
Member

@mycroes mycroes commented Jun 2, 2025

No description provided.

@mycroes mycroes requested a review from Copilot June 2, 2025 21:19
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the GitHub Actions workflow for .NET projects.

  • Removes the defaults block for run shell configuration.
  • Adds a new Setup .NET step to support both .NET 6 and 7.
  • Updates versions for GitVersion, artifact actions, and adjusts the operating system matrix.
Comments suppressed due to low confidence (4)

.github/workflows/dotnet.yml:40

  • Confirm that pinning GitVersion to '6.0.x' instead of '6.x' aligns with your intended version compatibility requirements.
versionSpec: '6.0.x'

.github/workflows/dotnet.yml:74

  • Double-check that replacing 'macos-latest' with 'macos-13' fully supports all dependent steps and test environments.
os: [windows-latest, ubuntu-latest, macos-13]

.github/workflows/dotnet.yml:33

  • Ensure that the multi-line specification for multiple .NET versions is supported by actions/setup-dotnet@v3 and behaves as expected during the workflow execution.
dotnet-version: |
          6.x
          7.x

.github/workflows/dotnet.yml:100

  • [nitpick] Verify that using a negated ACT environment variable as the condition for caching is logically sound and covers all your intended scenarios.
if: ${{ !env.ACT }}

@seilc1
Copy link

seilc1 commented Jun 4, 2025

I think we had a similar issue in the recent past: the ports used are not that eagerly freed, so that if a fixed port is used, it can happen that it's still considered in use.

There are (atleast) two unreliable solutions:

  1. increment the port each time -> increased potential to conflict with other applications
  2. try to get a free port by using new TcpListener(IPAddress.Loopback, 0) -> can still be flaky in multi threading scenarios

what's the best way to provide you a fix suggestion?

@seilc1
Copy link

seilc1 commented Jun 5, 2025

    [TestClass]
    public partial class S7NetTests : IDisposable
    {
        #region Constants
        const int DB2 = 2;
        const int DB4 = 4;
        const short TestServerPortStart = 31122;
        const string TestServerIp = "127.0.0.1";
        #endregion

        #region Private fields
        Plc plc;
        private readonly short testServerPort;
        #endregion

        private static readonly object _lock = new();
        private static short currentTestServerPort = TestServerPortStart;

        #region Constructor
        /// <summary>
        /// Create a plc that will connect to localhost (Snap 7 server) and connect to it
        /// </summary>
        public S7NetTests()
        {
            lock (_lock)
            {
                currentTestServerPort++;
                testServerPort = currentTestServerPort;
            }

            plc = CreatePlc(testServerPort);

        }

        private static Plc CreatePlc(short port)
        {
            return new Plc(CpuType.S7300, TestServerIp, port, 0, 2);
        }

        [TestInitialize]
        public void Setup()
        {
            S7TestServer.Start(testServerPort);
            plc.Open();
        }

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

Successfully merging this pull request may close these issues.

2 participants