Primitive type such as string and int have a special ability. Such as make it const, use it on default parameter (because it is const), or make it a base class of enum (actually it only for integer but that also included in this proposal)
I think it useful if we could have struct that contain only primitive things also being primitive. And if it contains only integer it should also be integer. So struct that which is primitive can be const field. Can be set default parameter. And if it is integer struct it would be able to make enum from it
```C#
public struct Color
{
public byte R,G,B,A;
}
public enum Colors : Color // all field is byte so it is also integer
{
Red = new Color(255,0,0,255),
Green = new Color(0,255,0,255),
Blue = new Color(0,0,255,255),
}
public struct Vector3
{
public float X,Y,Z;
public const Zero = new Vector3(0,0,0);
}
public struct Config
{
public Vector3 Up;
public string Name;
public static void SetConfigToEnv(Config con = new Config("test",new Vector3(0,1,0)))
{
}
}
```
This should also cope with Tuple and other generic struct. If its generic contains only primitive it would became primitive
Mildly related: #15079
Related to const string, I want const binary data. const strings are stored in the User String matadata table. the User String stream is actually a blob heap and can contain any binary data. For instance, const binary is required for Utf8String literals. This should be general mechanism for not only Utf8String but arbitrary types.
The enum part of this proposal sounds pretty similar to https://github.com/dotnet/roslyn/issues/6739.
Have found idea #16193
I think my proposal could be extend a bit to cover this
By count enum as integer type. Then count struct that contains only enum and integer type as integer type
Like so it could be done as
```C#
struct Thing
{
public Colors Color;
public Models Model;
}
enum Things : Thing
{
RedBox = new Thing(Models.Box,Colors.Red),
BlueBox = new Thing(Models.Box,Colors.Blue),
RedSphere = new Thing(Models.Sphere,Colors.Red),
BlueSphere = new Thing(Models.Sphere,Colors.Blue),
}
enum Colors : Color
{
Red: new Color(255,0,0),
Green: new Color(0,255,0),
Blue: new Color(0,0,255),
}
enum Models
{
Sphere:0,
Box:1,
}
////
var obj = Things.RedBox;
var objColor = Things.RedBox.Color;
```
Most helpful comment
Related to
const string, I wantconstbinary data.const strings are stored in the User String matadata table. the User String stream is actually a blob heap and can contain any binary data. For instance,constbinary is required forUtf8Stringliterals. This should be general mechanism for not onlyUtf8Stringbut arbitrary types.