C# Compilation issues in Visual Studio compared to Online Editor

I am working my way through the c# learning track and have a query about the switch statements in the football match exercise.

The following snippet of code works in the online editor but when I bring it into Visual Studio 2022, I get an error that the type or namespace ‘Foul’ cannot be found in the AnalyzeOffField method.

Does the online editor automatically create these types in the background when running the tests ?

public static string AnalyzeOnField(int shirtNum)
{
switch (shirtNum)
{
case 1:
return “goalie”;
break;
case 2:
return “left back”;
break;
case 3:
case 4:
return “center back”;
break;
case 5:
return “right back”;
break;
case 6:
case 7:
case 8:
return “midfielder”;
break;
case 9:
return “left wing”;
break;
case 10:
return “striker”;
case 11:
return “right wing”;
break;
default:
throw new ArgumentOutOfRangeException(nameof(shirtNum));
}
}

    public static string AnalyzeOffField(object report)
    {
        switch (report)
        {
            case Foul foul:
                return "The referee deemed a foul.";
            case int supporters:
                return $"There are {supporters} supporters at the match.";
            case string announcement:
                return announcement;
            default: throw new ArgumentOutOfRangeException();
        }
    }

That switch statement in AnalyzeOffField is using type pattern matching, which is new as of C# 9, I think. Is your local project configured to use an older version?

I am using C#11 in visual studio, so it should be available if it was introduced in c#9 ?

The Foul type and some others are defined in a separate source file named OffFieldActivitiesAndCharacters.cs. If you used the Exercism CLI to download the exercise, it ought to be in the same folder as everthing else.