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

CodeGenerator.MSBuild v3.4.3 does not work with records #7161

Closed
wdspider opened this issue Jul 18, 2021 · 2 comments
Closed

CodeGenerator.MSBuild v3.4.3 does not work with records #7161

wdspider opened this issue Jul 18, 2021 · 2 comments
Labels
stale Issues with no activity for the past 6 months

Comments

@wdspider
Copy link

Using this basic grain:

    public sealed record LocationInfo
    {
        public static LocationInfo Default { get; } = new LocationInfo { Id = -1, Name = "Unknown Location" };

        public long Id { get; init; }
        public string Name { get; init; } = "";
    }

    public interface ILocationGrain : IGrainWithIntegerKey
    {
        public Task<LocationInfo> GetLocationInfoAsync();
        public Task SetInfoAsync(LocationInfo locationInfo);
    }

    public sealed class LocationGrain : Grain, ILocationGrain
    {
        #region Internal State
        private LocationInfo locationInfo = LocationInfo.Default;
        #endregion

        #region ILocationGrain Implementation
        Task<LocationInfo> ILocationGrain.GetLocationInfoAsync() => Task.FromResult(locationInfo);

        Task ILocationGrain.SetInfoAsync(LocationInfo info)
        {
            locationInfo = info;
            return Task.CompletedTask;
        }
        #endregion
    }

The code gen fails with these errors:

1>Orleans.CodeGenerator - command-line = SourceToSource C:\Repos\src\server\Abstractions\obj\Debug\net6.0\Abstractions.orleans.g.args.txt
1>EXEC : warning : attempted to get TypeSyntax for unknown (error) type, "LocationInfo". Possible reason: None. Possible candidates:
1>EXEC : warning : attempted to get TypeSyntax for unknown (error) type, "LocationInfo". Possible reason: None. Possible candidates:
1>EXEC : warning : attempted to get TypeSyntax for unknown (error) type, "LocationInfo". Possible reason: None. Possible candidates:
1>EXEC : warning : attempted to get TypeSyntax for unknown (error) type, "LocationInfo". Possible reason: None. Possible candidates:
1>C:\Repos\src\server\Abstractions\obj\Debug\net6.0\Abstractions.orleans.g.cs(102,45,102,57): error CS0246: The type or namespace name 'LocationInfo' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Repos\src\server\Abstractions\obj\Debug\net6.0\Abstractions.orleans.g.cs(102,118,102,138): error CS0539: 'OrleansCodeGenLocationGrainReference.GetLocationInfoAsync()' in explicit interface declaration is not found among members of the interface that can be implemented
1>C:\Repos\src\server\Abstractions\obj\Debug\net6.0\Abstractions.orleans.g.cs(107,117,107,129): error CS0246: The type or namespace name 'LocationInfo' could not be found (are you missing a using directive or an assembly reference?)
1>C:\Repos\src\server\Abstractions\obj\Debug\net6.0\Abstractions.orleans.g.cs(107,104,107,116): error CS0539: 'OrleansCodeGenLocationGrainReference.SetInfoAsync(LocationInfo)' in explicit interface declaration is not found among members of the interface that can be implemented
1>C:\Repos\src\server\Abstractions\obj\Debug\net6.0\Abstractions.orleans.g.cs(57,99,57,157): error CS0535: 'OrleansCodeGenLocationGrainReference' does not implement interface member 'ILocationGrain.GetLocationInfoAsync()'
1>C:\Repos\src\server\Abstractions\obj\Debug\net6.0\Abstractions.orleans.g.cs(57,99,57,157): error CS0535: 'OrleansCodeGenLocationGrainReference' does not implement interface member 'ILocationGrain.SetInfoAsync(LocationInfo)'
1>Done building project "Abstractions.csproj" -- FAILED.

The above errors go away if I change LocationInfo to a class rather than a record. In new projects, I prefer for my POCO objects to be records instead of classes so that they can take advantage of the build in immutablity and value equals. Please fix.

@nkosi23
Copy link

nkosi23 commented Jul 19, 2021

Support for record types will be available in Orleans version 3 5.0 according to this recently merged pull request:

#7119

However I do not know when 3.5.0 will be released.

@ReubenBond
Copy link
Member

We are preparing the 3.5.0 release. It's almost ready to be published. We expect to publish it today.

@ghost ghost locked as resolved and limited conversation to collaborators Oct 3, 2021
@ghost ghost added the stale Issues with no activity for the past 6 months label Dec 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stale Issues with no activity for the past 6 months
Projects
None yet
Development

No branches or pull requests

3 participants