Repository: dotnet/maui
File: src/Controls/src/Build.Tasks/CompiledMarkupExtensions/StaticExtension.cs (C#)

Code before:
					return [Instruction.Create(OpCodes.Ldc_I4, (char)fieldDef.Constant)];
				if (TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.Single))
					return [Instruction.Create(OpCodes.Ldc_R4, (float)fieldDef.Constant)];
				if (TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.Double))
					return [Instruction.Create(OpCodes.Ldc_R8, (double)fieldDef.Constant)];
				if (TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.Byte) || TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.Int16) || TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.Int32))
					return [Instruction.Create(OpCodes.Ldc_I4, (int)fieldDef.Constant)];
				if (TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.SByte) || TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.UInt16) || TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.UInt32))
					return [Instruction.Create(OpCodes.Ldc_I4, (uint)fieldDef.Constant)];
				if (TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.Int64))
					return [Instruction.Create(OpCodes.Ldc_I8, (long)fieldDef.Constant)];
				if (TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.UInt64))
					return [Instruction.Create(OpCodes.Ldc_I8, (ulong)fieldDef.Constant)];

				//enum values
				if (memberRef.ResolveCached(context.Cache).IsEnum)
				{
					if (fieldDef.Constant is long)
						return [Instruction.Create(OpCodes.Ldc_I8, (long)fieldDef.Constant)];
					if (fieldDef.Constant is ulong)
						return [Instruction.Create(OpCodes.Ldc_I8, (ulong)fieldDef.Constant)];
					if (fieldDef.Constant is uint)
						return [Instruction.Create(OpCodes.Ldc_I4, (uint)fieldDef.Constant)];
					//everything else will cast just fine to an int
					return [Instruction.Create(OpCodes.Ldc_I4, (int)fieldDef.Constant)];
				}
			}

			memberRef = propertyDef.PropertyType;
			var getterDef = module.ImportReference(propertyDef.GetMethod);
			return [Instruction.Create(OpCodes.Call, getterDef)];
		}

		public static FieldReference GetFieldReference(XamlCache cache, TypeReference typeRef, string fieldName, ModuleDefinition module)
		{
			FieldReference fRef = typeRef.GetField(cache, fd => fd.Name == fieldName
														&& fd.IsStatic
														&& IsPublicOrVisibleInternal(fd, module), out TypeReference declaringTypeReference);
			if (fRef != null)
			{
				fRef = module.ImportReference(fRef.ResolveGenericParameters(declaringTypeReference));
				fRef.FieldType = module.ImportReference(fRef.FieldType);
			}
			return fRef;
		}

		static bool IsPublicOrVisibleInternal(FieldDefinition fd, ModuleDefinition module)
		{
			if (fd.IsPublic)
				return true;
			if (fd.IsAssembly)

Review comment (suggestion):
```suggestion
					if (fieldDef.Constant is sbyte)
```

Code after:
					return [Instruction.Create(OpCodes.Ldc_I4, (char)fieldDef.Constant)];
				if (TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.Single))
					return [Instruction.Create(OpCodes.Ldc_R4, (float)fieldDef.Constant)];
				if (TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.Double))
					return [Instruction.Create(OpCodes.Ldc_R8, (double)fieldDef.Constant)];
				if (TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.Byte) || TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.Int16) || TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.Int32))
					return [Instruction.Create(OpCodes.Ldc_I4, (int)fieldDef.Constant)];
				if (TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.SByte) || TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.UInt16) || TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.UInt32))
					return [Instruction.Create(OpCodes.Ldc_I4, (uint)fieldDef.Constant)];
				if (TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.Int64))
					return [Instruction.Create(OpCodes.Ldc_I8, (long)fieldDef.Constant)];
				if (TypeRefComparer.Default.Equals(memberRef, module.TypeSystem.UInt64))
					return [Instruction.Create(OpCodes.Ldc_I8, (ulong)fieldDef.Constant)];

				//enum values
				if (memberRef.ResolveCached(context.Cache).IsEnum)
				{
					if (fieldDef.Constant is long)
						return [Instruction.Create(OpCodes.Ldc_I8, (long)fieldDef.Constant)];
					if (fieldDef.Constant is ulong)
						return [Instruction.Create(OpCodes.Ldc_I8, (ulong)fieldDef.Constant)];
					if (fieldDef.Constant is uint)
						return [Instruction.Create(OpCodes.Ldc_I4, (uint)fieldDef.Constant)];
					if (fieldDef.Constant is byte)
						return [Instruction.Create(OpCodes.Ldc_I4, (int)(byte)fieldDef.Constant)];
						if (fieldDef.Constant is sbyte)
						return [Instruction.Create(OpCodes.Ldc_I4, (int)(sbyte)fieldDef.Constant)];
					if (fieldDef.Constant is short)
						return [Instruction.Create(OpCodes.Ldc_I4, (int)(short)fieldDef.Constant)];
					if (fieldDef.Constant is ushort)
						return [Instruction.Create(OpCodes.Ldc_I4, (int)(ushort)fieldDef.Constant)];

					//fallback
					return [Instruction.Create(OpCodes.Ldc_I4, (int)fieldDef.Constant)];
				}
			}

			memberRef = propertyDef.PropertyType;
			var getterDef = module.ImportReference(propertyDef.GetMethod);
			return [Instruction.Create(OpCodes.Call, getterDef)];
		}

		public static FieldReference GetFieldReference(XamlCache cache, TypeReference typeRef, string fieldName, ModuleDefinition module)
		{
			FieldReference fRef = typeRef.GetField(cache, fd => fd.Name == fieldName
														&& fd.IsStatic
														&& IsPublicOrVisibleInternal(fd, module), out TypeReference declaringTypeReference);
			if (fRef != null)
			{
				fRef = module.ImportReference(fRef.ResolveGenericParameters(declaringTypeReference));
				fRef.FieldType = module.ImportReference(fRef.FieldType);