Skip to content

Commit 605ff6f

Browse files
authored
Update to Preview7 SDK (#106333)
* Update to Preview7 SDK * Enable use of DefaultValueAttribute in trimming test * Fix the _DefaultValueAttributeSupport in generated trimming tests * Make DefaultValueAttributeCtorTest trimming test enable _DefaultValueAttributeSupport * Condition some DefaultValueAttributeTests on DefaultValueAttribute.IsSupported switch * Fix AmbientValueAttribute when IDesignerHost.IsSupported is false Throw only when type constructor is used. Fix tests to condition on this. * Condition some XmlSerializer tests These tests serialize types that use DefaultValueAttribute which is disabled. * Update to final Preview7 versions * Fix ToolboxItemAttributeTests when IDesignerHost.IsSupported is false
1 parent 7963a49 commit 605ff6f

File tree

12 files changed

+50
-18
lines changed

12 files changed

+50
-18
lines changed

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"sdk": {
3-
"version": "9.0.100-preview.6.24328.19",
3+
"version": "9.0.100-preview.7.24407.12",
44
"allowPrerelease": true,
55
"rollForward": "major"
66
},
77
"tools": {
8-
"dotnet": "9.0.100-preview.6.24328.19"
8+
"dotnet": "9.0.100-preview.7.24407.12"
99
},
1010
"msbuild-sdks": {
1111
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24408.2",

src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/AmbientValueAttribute.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public sealed class AmbientValueAttribute : Attribute
1818
/// This is the default value.
1919
/// </summary>
2020
private object? _value;
21+
private static readonly object? s_throwSentinel = IDesignerHost.IsSupported ? null : new();
2122

2223
/// <summary>
2324
/// Initializes a new instance of the <see cref='System.ComponentModel.AmbientValueAttribute'/> class, converting the
@@ -32,6 +33,7 @@ public AmbientValueAttribute([DynamicallyAccessedMembers(DynamicallyAccessedMemb
3233
Debug.Assert(IDesignerHost.IsSupported, "Runtime instantiation of this attribute is not allowed with trimming.");
3334
if (!IDesignerHost.IsSupported)
3435
{
36+
_value = s_throwSentinel;
3537
return;
3638
}
3739

@@ -142,7 +144,7 @@ public AmbientValueAttribute(object? value)
142144
public object? Value {
143145
get
144146
{
145-
if (!IDesignerHost.IsSupported)
147+
if (!IDesignerHost.IsSupported && ReferenceEquals(_value, s_throwSentinel))
146148
{
147149
throw new ArgumentException(SR.RuntimeInstanceNotAllowed);
148150
}

src/libraries/System.ComponentModel.TypeConverter/tests/AmbientValueAttributeTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ namespace System.ComponentModel.Tests
88
{
99
public class AmbientValueAttributeTests
1010
{
11-
[Theory]
11+
public static bool IDesignerHostIsSupported => AppContext.TryGetSwitch("System.ComponentModel.Design.IDesignerHost.IsSupported", out bool isSupported) ? isSupported : true;
12+
13+
[ConditionalTheory(nameof(IDesignerHostIsSupported))]
1214
[InlineData(null, null, null)]
1315
[InlineData(typeof(int*), "1", null)]
1416
[InlineData(typeof(string), "1", "1")]

src/libraries/System.ComponentModel.TypeConverter/tests/ToolboxItemAttributeTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ namespace System.ComponentModel
88
{
99
public class ToolboxItemAttributeTests
1010
{
11+
internal static bool IDesignerHostIsSupported => AppContext.TryGetSwitch("System.ComponentModel.Design.IDesignerHost.IsSupported", out bool isSupported) ? isSupported : true;
12+
1113
[Theory]
1214
[InlineData(true)]
1315
[InlineData(false)]
1416
public void Ctor_Bool(bool defaultType)
1517
{
18+
if (!IDesignerHostIsSupported && defaultType)
19+
{
20+
AssertExtensions.Throws<NotSupportedException>(() => new ToolboxItemAttribute(defaultType));
21+
return;
22+
}
23+
1624
var attribute = new ToolboxItemAttribute(defaultType);
1725
if (defaultType)
1826
{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<Project DefaultTargets="Build">
22
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />
33

4+
<ItemGroup>
5+
<TestConsoleAppSourceFiles Include="TypeConverterAttributeStringArgCtorTest.cs">
6+
<EnabledProperties>_DefaultValueAttributeSupport</EnabledProperties>
7+
</TestConsoleAppSourceFiles>
8+
<TestConsoleAppSourceFiles Include="TypeConverterAttributeTypeArgCtorTest.cs">
9+
<EnabledProperties>_DefaultValueAttributeSupport</EnabledProperties>
10+
</TestConsoleAppSourceFiles>
11+
<TestConsoleAppSourceFiles Include="TypeDescriptionProviderAttributeCtorTest.cs" />
12+
</ItemGroup>
13+
414
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" />
515
</Project>

src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ static XmlSerializerTests()
4343
}
4444
#endif
4545

46+
public static bool DefaultValueAttributeIsSupported => AppContext.TryGetSwitch("System.ComponentModel.DefaultValueAttribute.IsSupported", out bool isEnabled) ? isEnabled : true;
47+
4648
[Fact]
4749
public static void Xml_TypeWithDateTimePropertyAsXmlTime()
4850
{
@@ -823,7 +825,7 @@ public static void Xml_TypeWithTimeSpanProperty()
823825
Assert.StrictEqual(obj.TimeSpanProperty, deserializedObj.TimeSpanProperty);
824826
}
825827

826-
[Fact]
828+
[ConditionalFact(nameof(DefaultValueAttributeIsSupported))]
827829
public static void Xml_TypeWithDefaultTimeSpanProperty()
828830
{
829831
var obj = new TypeWithDefaultTimeSpanProperty { TimeSpanProperty2 = new TimeSpan(0, 1, 0) };
@@ -868,7 +870,7 @@ public static void Xml_DeserializeEmptyTimeSpanType()
868870
}
869871
}
870872

871-
[Fact]
873+
[ConditionalFact(nameof(DefaultValueAttributeIsSupported))]
872874
public static void Xml_TypeWithDateTimeOffsetProperty()
873875
{
874876
var now = new DateTimeOffset(DateTime.Now);
@@ -893,7 +895,7 @@ public static void Xml_TypeWithDateTimeOffsetProperty()
893895
Assert.True(deserializedObj.NullableDTOWithDefault == null);
894896
}
895897

896-
[Fact]
898+
[ConditionalFact(nameof(DefaultValueAttributeIsSupported))]
897899
public static void Xml_DeserializeTypeWithEmptyDateTimeOffsetProperties()
898900
{
899901
//var def = DateTimeOffset.Parse("3/17/1977 5:00:01 PM -05:00"); // "1977-03-17T17:00:01-05:00"

src/libraries/System.Runtime/tests/System.Runtime.Tests/System/ComponentModel/DefaultValueAttributeTests.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ namespace System.ComponentModel.Tests
1212
{
1313
public class DefaultValueAttributeTests
1414
{
15+
public static bool DefaultValueAttributeIsSupported => AppContext.TryGetSwitch("System.ComponentModel.DefaultValueAttribute.IsSupported", out bool isEnabled) ? isEnabled : true;
16+
1517
[Fact]
16-
public static void Ctor()
18+
public static void Ctor_value()
1719
{
1820
Assert.Equal((object)true, new DefaultValueAttribute(true).Value);
1921
Assert.Equal((object)false, new DefaultValueAttribute(false).Value);
@@ -37,7 +39,11 @@ public static void Ctor()
3739
Assert.Equal("test", new DefaultValueAttribute("test").Value);
3840

3941
Assert.Equal("test", new DefaultValueAttribute((object)"test").Value);
42+
}
4043

44+
[ConditionalFact(nameof(DefaultValueAttributeIsSupported))]
45+
public static void Ctor_type_string()
46+
{
4147
Assert.Equal(DayOfWeek.Monday, new DefaultValueAttribute(typeof(DayOfWeek), "Monday").Value);
4248
Assert.Equal(TimeSpan.FromHours(1), new DefaultValueAttribute(typeof(TimeSpan), "1:00:00").Value);
4349

@@ -63,7 +69,7 @@ public class CustomType2
6369
public int Value { get; set; }
6470
}
6571

66-
[Fact]
72+
[ConditionalFact(nameof(DefaultValueAttributeIsSupported))]
6773
public static void Ctor_CustomTypeConverter()
6874
{
6975
TypeDescriptor.AddAttributes(typeof(CustomType), new TypeConverterAttribute(typeof(CustomConverter)));
@@ -99,7 +105,7 @@ public void Ctor_TypeDescriptorNotFound_ExceptionFallback(Type type, bool return
99105
}, type.ToString(), returnNull.ToString(), stringToConvert, expectedValue.ToString()).Dispose();
100106
}
101107

102-
[Theory]
108+
[ConditionalTheory(nameof(DefaultValueAttributeIsSupported))]
103109
[InlineData(typeof(CustomType2))]
104110
[InlineData(typeof(DefaultValueAttribute))]
105111
public static void Ctor_DefaultTypeConverter_Null(Type type)

src/libraries/System.Runtime/tests/System.Runtime.Tests/TrimmingTests/System.Runtime.TrimmingTests.proj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
<TestConsoleAppSourceFiles Include="DebuggerVisualizerAttributeTests.cs" >
2525
<EnabledProperties>DebuggerSupport</EnabledProperties>
2626
</TestConsoleAppSourceFiles>
27-
<TestConsoleAppSourceFiles Include="DefaultValueAttributeCtorTest.cs" />
27+
<TestConsoleAppSourceFiles Include="DefaultValueAttributeCtorTest.cs">
28+
<EnabledProperties>_DefaultValueAttributeSupport</EnabledProperties>
29+
</TestConsoleAppSourceFiles>
2830
<TestConsoleAppSourceFiles Include="GenericArraySortHelperTest.cs" />
2931
<TestConsoleAppSourceFiles Include="InheritedAttributeTests.cs" />
3032
<TestConsoleAppSourceFiles Include="InterfacesOnArrays.cs" />

src/mono/sample/wasm/blazor-frame/blazor.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
<ItemGroup>
1313
<!-- TODO un-pin this when it's possible -->
14-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0-preview.6.24328.4" />
15-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0-preview.6.24328.4" PrivateAssets="all" />
14+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0-preview.7.24406.2" />
15+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0-preview.7.24406.2" PrivateAssets="all" />
1616
</ItemGroup>
1717

1818
</Project>

src/mono/wasm/testassets/WasmOnAspNetCore/AspNetCoreServer/AspNetCoreServer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.0-preview.6.24328.4" />
13+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="9.0.0-preview.7.24406.2" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

0 commit comments

Comments
 (0)