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

Code generation does not detect default value type mismatches when generating C# #72

Closed
chwarr opened this issue Jul 15, 2015 · 1 comment
Assignees
Labels

Comments

@chwarr
Copy link
Member

chwarr commented Jul 15, 2015

Given the following .bond file

namespace type_mismatch;

struct HasUint64Field
{
    0: uint64 ui64_field = "this is a string value";
}

The following command runs without error and writes a .cs file.

> .\gbc.exe c# .\default_type_mismatch.bond

The .cs file is not valid however. Notice the ui64_field initialization.

...
namespace type_mismatch
{
    using System.Collections.Generic;

    [global::Bond.Schema]
    [System.CodeDom.Compiler.GeneratedCode("gbc", "3.05")]
    public partial class HasUint64Field
    {
        [global::Bond.Id(0)]
        public ulong ui64_field { get; set; }

        public HasUint64Field()
            : this("type_mismatch.HasUint64Field", "HasUint64Field")
        {}

        protected HasUint64Field(string fullName, string name)
        {
            ui64_field = "this is a string value";
        }
    }
} // type_mismatch

On the other hand, C++ code generation fails with the following error, though it does write _reflection.h and creates _types.h

> .\gbc.exe c++ .\default_type_mismatch.bond
gbc.exe: defaultValue: impossible happened.

Version details:

> .\gbc.exe -V
Bond Compiler 3.05, (C) Microsoft

This gbc is from Bond.CSharp 3.0.6.

@chwarr chwarr changed the title Code generation does not detect incompatible types when generating C# Code generation does not detect default value types mismatches when generating C# Jul 15, 2015
@chwarr chwarr changed the title Code generation does not detect default value types mismatches when generating C# Code generation does not detect default value type mismatches when generating C# Jul 15, 2015
@chwarr chwarr added the bug label Jan 20, 2016
@chwarr chwarr self-assigned this Feb 25, 2016
lalo added a commit that referenced this issue Jun 17, 2016
- Fail when struct field has default value of 'nothing'
- Fail when enum field doesn't have default value
- Validate aliases' default value
- Validate default value type mistmatches
- Validate default value out-of-range values

Fixes #177, fixes #164, fixes #128, fixes #73, fixes #72
lalo added a commit that referenced this issue Jun 22, 2016
- Validate default value type mistmatches (fixes #72, fixes #128)
- Validate default value out-of-range values (fixes #73)
- Fail when struct field has default value of 'nothing' (fixes #164)
- Fail when enum field doesn't have default value (fixes #177)
- Validate default value of type aliases
@lalo lalo closed this as completed in 90b8bad Jun 22, 2016
@chwarr
Copy link
Member Author

chwarr commented Aug 23, 2016

Bond version 4.3.0 is now live on NuGet.org. These changes are included in that version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant