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

Error cs0568 is making me unable to build the project #32

Open
pj8055 opened this issue Jul 21, 2023 · 6 comments
Open

Error cs0568 is making me unable to build the project #32

pj8055 opened this issue Jul 21, 2023 · 6 comments

Comments

@pj8055
Copy link

pj8055 commented Jul 21, 2023

As i said in the title the error is making me unable to build due to the "public Move()" not allowing itself to be null or something to quote exactly its "structs cannot contain explicit parameterless constructors". im not entirely sure as im not used to developing in c# except some basics in unity so im unsure of what to do. i read that i might have to update to c# 10+ but i want to make sure first.

@CREAsTIVE
Copy link

more details? (line code of error)

@mcthouacbb
Copy link

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/constructor-errors#constructors-in-struct-types:~:text=generates%20this%20warning.-,Constructors%20in%20struct%20types,-CS0568%20%2D%20Structs

It says here that CS0568 is only turned on for C# 9 and earlier, so it looks like the simplest solution will probably be to upgrade to C# 10

@pj8055
Copy link
Author

pj8055 commented Jul 21, 2023

	public bool IsPromotion => move.IsPromotion;
	public bool IsCastles => move.MoveFlag == Chess.Move.CastleFlag;
	public bool IsNull => move.IsNull;
	public ushort RawValue => move.Value;
	public static readonly Move NullMove = new();

	readonly Chess.Move move;
	readonly ushort pieceTypeData;

	/// <summary>
	/// Create a null/invalid move.
	/// This is simply an invalid move that can be used as a placeholder until a valid move has been found
	/// </summary>
	public Move() // **Right here is where the bug is**
	{
		move = Chess.Move.NullMove;
		pieceTypeData = 0;
	}

@pj8055
Copy link
Author

pj8055 commented Jul 21, 2023

thank you i will

@CharlesCapel
Copy link

Same error spot (Move.cs line 29) and can't build too.

Error CS0568
Structs cannot contain explicit parameterless constructors

@bean-b
Copy link

bean-b commented Jul 23, 2023

same : warning CS8625: Cannot convert null literal to non-nullable reference type.

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

5 participants