EddieV
EddieV
CC#
Created by EddieV on 6/4/2023 in #help
❔ Non-nullable property must contain a non-null value when exiting constructor
So the console tells me, Maelstrom must not be null when existing in the constructor.
12 replies
CC#
Created by EddieV on 6/4/2023 in #help
❔ Non-nullable property must contain a non-null value when exiting constructor
Here's the code. I'm doing an exercise, if player chooses "small", there won't be maelstroms in the game
12 replies
CC#
Created by EddieV on 6/4/2023 in #help
❔ Non-nullable property must contain a non-null value when exiting constructor
public class World
{
public int[,] WorldState { get; set; }
public Fountain Fountain { get; set; }
public Pit[] Pits { get; set; }
public Maelstrom?[] Maelstroms { get; set; }
public Entrance Entrance { get; set; } = new Entrance();

public World(string? size)
{

switch (size)
{
case "small":
WorldState = new int[4, 4];
Fountain = new Fountain(new Point(3, 1));
Pits = new Pit[1] { new Pit(new Point(1, 1)) };
break;

case "medium":
WorldState = new int[6, 6];
Fountain = new Fountain(new Point(4, 3));
Pits = new Pit[2]
{
new Pit(new Point(3, 1)),
new Pit(new Point(2, 3))
};
Maelstroms = new Maelstrom[1] { new Maelstrom(new Point(4, 2))};
break;

case "large":
WorldState = new int[8, 8];
Fountain = new Fountain(new Point(4, 3));
Pits = new Pit[2]
{
new Pit(new Point(3, 1)),
new Pit(new Point(2, 3))
};
Maelstroms = new Maelstrom[1] { new Maelstrom(new Point(4, 2))};
break;

default:
throw new NotSupportedException("Invalid world size.");

}

}
public class World
{
public int[,] WorldState { get; set; }
public Fountain Fountain { get; set; }
public Pit[] Pits { get; set; }
public Maelstrom?[] Maelstroms { get; set; }
public Entrance Entrance { get; set; } = new Entrance();

public World(string? size)
{

switch (size)
{
case "small":
WorldState = new int[4, 4];
Fountain = new Fountain(new Point(3, 1));
Pits = new Pit[1] { new Pit(new Point(1, 1)) };
break;

case "medium":
WorldState = new int[6, 6];
Fountain = new Fountain(new Point(4, 3));
Pits = new Pit[2]
{
new Pit(new Point(3, 1)),
new Pit(new Point(2, 3))
};
Maelstroms = new Maelstrom[1] { new Maelstrom(new Point(4, 2))};
break;

case "large":
WorldState = new int[8, 8];
Fountain = new Fountain(new Point(4, 3));
Pits = new Pit[2]
{
new Pit(new Point(3, 1)),
new Pit(new Point(2, 3))
};
Maelstroms = new Maelstrom[1] { new Maelstrom(new Point(4, 2))};
break;

default:
throw new NotSupportedException("Invalid world size.");

}

}
12 replies
CC#
Created by EddieV on 6/4/2023 in #help
❔ Non-nullable property must contain a non-null value when exiting constructor
@🌈 Thinker 🌈 I did, however the Console still warns me about null
12 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
Anyway, thank y'all for the support.
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
I change target framework in the .csproj and everything works perfectly
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
Okay, I have no idea what just happened but I closed VSCode following @TeBeClone suggestion. Checking dotnet --list-sdks all of sudden it's now 7.0
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
Why 😦
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
But it seems uninstalling also complicated
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
I'm thinking about the last resort would be wiping .NET and its related components completely from my mac then do a clean install
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
@Florian Voß This is my .csproj file
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
No matter what I tried, the SDK kept stuck as 6.0.402
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
Ok, I think I found something: In the .csproj if I change TargetFramework to net7.0 -> no more code errors highlighted, but I couldn't run the programme If I keep it at nêt.0 -> all code erros highlights, but I could run the code
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
Even though I'm in the folder of a project
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
When I tried to run code, it said no project to run
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
The type or namespace name 'System' could not be found in the global namespace (are you missing an assembly reference?) @Diddy
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
I think I did something, now the omnisharp seems to work but my entired code is covered in blood red and I couldn't run it (could before lol)
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
Thank you, let me check it out
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
So how do I fix it? I have tried many things and none worked 😦
35 replies
CC#
Created by EddieV on 5/31/2023 in #help
❔ Cannot start OmniSharp due to error on MacOS
installer: Package name is Microsoft .NET SDK 6.0.408 (arm64)
installer: Upgrading at base path /
installer: The upgrade was successful.
installer: Package name is Microsoft .NET SDK 6.0.408 (arm64)
installer: Upgrading at base path /
installer: The upgrade was successful.
35 replies