I was tasked with working on a branch with a co-worker, but when I pulled their code, the branch would not build for me. We asked other developers to pull the code and see if their branches built, and it worked for everyone except me. One of the weird things is – there were more errors than I am currently getting, but after my co-worked pushed a commit (that didn’t touch the files in question) some of the errors went away.
I’d like to verify that I am receiving these errors inaccurately, and then get some help figuring out what I can do to resolve them.
We’re using .NET 6, but I ran into the same issues when trying to .NET 8.
The code with the compilation errors (I’ve added comments in the places where the errors appear):
public class DisplayColumn : Column<dynamic?, object>
{
private DisplayColumn(ColumnId id, dynamic? value, object attributes)
: base(id, value, attributes) { } // One of the errors is shown here: CS1975
public static class DisplayColumnFactory
{
public static DisplayColumn Create(Guid columnId, dynamic? value, object attribute)
{
var displayColumn = new DisplayColumn(
new(columnId), // The other error is shown here: CS8754
value,
attribute);
return displayColumn;
}
}
}
public abstract class GuidBase
{
public Guid Id { get; set; }
protected GuidBase(Guid guid)
{
if (guid == Guid.Empty)
{
throw new InvalidOperationException("Id value cannot be empty!");
}
Id = guid;
}
}
public class ColumnId : GuidBase
{
public ColumnId(Guid guid) : base(guid)
{
}
}
public abstract class Column<TValue, TAttribute>
{
public ColumnId Id { get; }
public TValue Value { get; }
public TAttribute Attributes { get; }
protected Column(ColumnId id, TValue value, TAttribute attributes)
{
Id = id;
Value = value;
Attributes = attributes;
}
}
Here are the errors I’m getting:
- This error is that it can’t pass a dynamic value from the constructor for DisplayColumn to the base Column class, despite the fact that Column takes an argument of dynamic Picture of Error
- This error is that it can’t find infer the constructor used (Picture of Error). It infers it fine in other classes AND infers it fine in Visual Studio’s auto-complete (Visual Studio showing that it can infer the type).
I’ve tried:
- Deleting and re-pulling the code base
- Updating Visual Studio
- Completely uninstalling and re-installing Visual Studio
- Upgrading to .NET 8
- Running
dotnet build
on the project without Visual Studio
But nothing gets rid of these errors. Help would be greatly appreciated.
Ben is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.