diff --git a/eng/common/templates/job/job.yml b/eng/common/templates/job/job.yml index 0b01531357e..01c0dd995e4 100644 --- a/eng/common/templates/job/job.yml +++ b/eng/common/templates/job/job.yml @@ -136,7 +136,7 @@ jobs: condition: and(succeeded(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT')) - ${{ if and(eq(parameters.runAsPublic, 'false'), eq(variables['System.TeamProject'], 'internal')) }}: - - task: NuGetAuthenticate@0 + - task: NuGetAuthenticate@1 - ${{ if and(ne(parameters.artifacts.download, 'false'), ne(parameters.artifacts.download, '')) }}: - task: DownloadPipelineArtifact@2 diff --git a/eng/common/templates/job/publish-build-assets.yml b/eng/common/templates/job/publish-build-assets.yml index 3b25fd97923..d9c5b4aaf9b 100644 --- a/eng/common/templates/job/publish-build-assets.yml +++ b/eng/common/templates/job/publish-build-assets.yml @@ -72,7 +72,7 @@ jobs: condition: ${{ parameters.condition }} continueOnError: ${{ parameters.continueOnError }} - - task: NuGetAuthenticate@0 + - task: NuGetAuthenticate@1 - task: PowerShell@2 displayName: Publish Build Assets diff --git a/eng/common/templates/post-build/post-build.yml b/eng/common/templates/post-build/post-build.yml index d64236b28cf..bbc010fe732 100644 --- a/eng/common/templates/post-build/post-build.yml +++ b/eng/common/templates/post-build/post-build.yml @@ -169,7 +169,7 @@ stages: # This is necessary whenever we want to publish/restore to an AzDO private feed # Since sdk-task.ps1 tries to restore packages we need to do this authentication here # otherwise it'll complain about accessing a private feed. - - task: NuGetAuthenticate@0 + - task: NuGetAuthenticate@1 displayName: 'Authenticate to AzDO Feeds' # Signing validation will optionally work with the buildmanifest file which is downloaded from @@ -267,7 +267,7 @@ stages: BARBuildId: ${{ parameters.BARBuildId }} PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }} - - task: NuGetAuthenticate@0 + - task: NuGetAuthenticate@1 - task: PowerShell@2 displayName: Publish Using Darc diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index e8def7e6a85..5c3b2a1e416 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -601,7 +601,15 @@ function InitializeBuildTool() { ExitWithExitCode 1 } $dotnetPath = Join-Path $dotnetRoot (GetExecutableFileName 'dotnet') - $buildTool = @{ Path = $dotnetPath; Command = 'msbuild'; Tool = 'dotnet'; Framework = 'net8.0' } + + # Use override if it exists - commonly set by source-build + if ($null -eq $env:_OverrideArcadeInitializeBuildToolFramework) { + $initializeBuildToolFramework="net8.0" + } else { + $initializeBuildToolFramework=$env:_OverrideArcadeInitializeBuildToolFramework + } + + $buildTool = @{ Path = $dotnetPath; Command = 'msbuild'; Tool = 'dotnet'; Framework = $initializeBuildToolFramework } } elseif ($msbuildEngine -eq "vs") { try { $msbuildPath = InitializeVisualStudioMSBuild -install:$restore diff --git a/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs b/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs index fb30a603528..2801970f893 100644 --- a/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs +++ b/src/EFCore/Metadata/Builders/OwnedNavigationBuilder`.cs @@ -112,10 +112,10 @@ public virtual PropertyBuilder Property( /// blog => blog.Url). /// /// An object that can be used to configure the property. - public virtual PropertyBuilder PrimitiveCollection( + public virtual PrimitiveCollectionBuilder PrimitiveCollection( Expression> propertyExpression) => UpdateBuilder( - () => new PropertyBuilder( + () => new PrimitiveCollectionBuilder( DependentEntityType.Builder.PrimitiveCollection( Check.NotNull(propertyExpression, nameof(propertyExpression)).GetMemberAccess(), ConfigurationSource.Explicit)!.Metadata)); diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ComplexType.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ComplexType.cs index a50cd5cc13b..0631fee18f3 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ComplexType.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.ComplexType.cs @@ -2182,6 +2182,22 @@ public virtual void PrimitiveCollectionBuilder_methods_can_be_chained() .Entity() .ComplexProperty(e => e.CollectionQuarks) .PrimitiveCollection(e => e.Up) + .ElementType(t => t + .HasAnnotation("B", "C") + .HasConversion(typeof(long)) + .HasConversion(new CastingConverter()) + .HasConversion(typeof(long), typeof(CustomValueComparer)) + .HasConversion(typeof(long), new CustomValueComparer()) + .HasConversion(new CastingConverter()) + .HasConversion(new CastingConverter(), new CustomValueComparer()) + .HasConversion() + .HasConversion(new CustomValueComparer()) + .HasConversion>() + .HasMaxLength(2) + .HasPrecision(1) + .HasPrecision(1, 2) + .IsRequired() + .IsUnicode()) .IsRequired() .HasAnnotation("A", "V") .IsConcurrencyToken() diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.Generic.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.Generic.cs index 86a95fcf438..db66c25489d 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.Generic.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.Generic.cs @@ -861,6 +861,12 @@ protected class GenericTestComplexTypePrimitiveCollectionBuilder(Comp public override IMutableProperty Metadata => PrimitiveCollectionBuilder.Metadata; + public override TestElementTypeBuilder ElementType() + => new(PrimitiveCollectionBuilder.ElementType()); + + public override TestComplexTypePrimitiveCollectionBuilder ElementType(Action builderAction) + => Wrap(PrimitiveCollectionBuilder.ElementType(b => builderAction(new TestElementTypeBuilder(b)))); + protected virtual TestComplexTypePrimitiveCollectionBuilder Wrap( ComplexTypePrimitiveCollectionBuilder primitiveCollectionBuilder) => new GenericTestComplexTypePrimitiveCollectionBuilder(primitiveCollectionBuilder); @@ -1376,6 +1382,13 @@ public override TestPropertyBuilder Property( Expression> propertyExpression) => Wrap(OwnedNavigationBuilder.Property(propertyExpression)); + public override TestPrimitiveCollectionBuilder PrimitiveCollection(string propertyName) + => new GenericTestPrimitiveCollectionBuilder(OwnedNavigationBuilder.PrimitiveCollection(propertyName)); + + public override TestPrimitiveCollectionBuilder PrimitiveCollection( + Expression> propertyExpression) + => new GenericTestPrimitiveCollectionBuilder(OwnedNavigationBuilder.PrimitiveCollection(propertyExpression)); + public override TestNavigationBuilder Navigation( Expression> navigationExpression) where TNavigation : class diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonGeneric.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonGeneric.cs index c8f9ceeb03b..035b79b5651 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonGeneric.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonGeneric.cs @@ -3,6 +3,8 @@ #nullable enable +using System.Reflection; + namespace Microsoft.EntityFrameworkCore.ModelBuilding; public abstract partial class ModelBuilderTest @@ -928,6 +930,12 @@ protected virtual TestComplexTypePrimitiveCollectionBuilder Wrap( ComplexTypePrimitiveCollectionBuilder primitiveCollectionBuilder) => new NonGenericTestComplexTypePrimitiveCollectionBuilder(primitiveCollectionBuilder); + public override TestElementTypeBuilder ElementType() + => new(PrimitiveCollectionBuilder.ElementType()); + + public override TestComplexTypePrimitiveCollectionBuilder ElementType(Action builderAction) + => Wrap(PrimitiveCollectionBuilder.ElementType(b => builderAction(new TestElementTypeBuilder(b)))); + public override TestComplexTypePrimitiveCollectionBuilder HasAnnotation(string annotation, object? value) => Wrap(PrimitiveCollectionBuilder.HasAnnotation(annotation, value)); @@ -1442,6 +1450,17 @@ public override TestPropertyBuilder Property( OwnedNavigationBuilder.Property(memberInfo.GetMemberType(), memberInfo.GetSimpleMemberName())); } + public override TestPrimitiveCollectionBuilder PrimitiveCollection(string propertyName) + => new NonGenericTestPrimitiveCollectionBuilder(OwnedNavigationBuilder.PrimitiveCollection(propertyName)); + + public override TestPrimitiveCollectionBuilder PrimitiveCollection( + Expression> propertyExpression) + { + var memberInfo = propertyExpression.GetMemberAccess(); + return new NonGenericTestPrimitiveCollectionBuilder( + OwnedNavigationBuilder.PrimitiveCollection(memberInfo.GetMemberType(), memberInfo.GetSimpleMemberName())); + } + public override TestNavigationBuilder Navigation( Expression> navigationExpression) where TNavigation : class diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonRelationship.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonRelationship.cs index 493502d695d..38e40f93f45 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonRelationship.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.NonRelationship.cs @@ -2918,7 +2918,24 @@ public virtual void PrimitiveCollectionBuilder_methods_can_be_chained() => CreateModelBuilder() .Entity() .PrimitiveCollection(e => e.Up) + .ElementType(t => t + .HasAnnotation("B", "C") + .HasConversion(typeof(long)) + .HasConversion(new CastingConverter()) + .HasConversion(typeof(long), typeof(CustomValueComparer)) + .HasConversion(typeof(long), new CustomValueComparer()) + .HasConversion(new CastingConverter()) + .HasConversion(new CastingConverter(), new CustomValueComparer()) + .HasConversion() + .HasConversion(new CustomValueComparer()) + .HasConversion>() + .HasMaxLength(2) + .HasPrecision(1) + .HasPrecision(1, 2) + .IsRequired() + .IsUnicode()) .IsRequired() + .IsRequired(false) .HasAnnotation("A", "V") .IsConcurrencyToken() .ValueGeneratedNever() @@ -2931,8 +2948,7 @@ public virtual void PrimitiveCollectionBuilder_methods_can_be_chained() .HasValueGenerator() .HasValueGenerator(typeof(CustomValueGenerator)) .HasValueGeneratorFactory() - .HasValueGeneratorFactory(typeof(CustomValueGeneratorFactory)) - .IsRequired(); + .HasValueGeneratorFactory(typeof(CustomValueGeneratorFactory)); [ConditionalFact] public virtual void Can_set_primary_key_by_convention_for_user_specified_shadow_primitive_collection() diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.OwnedTypes.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.OwnedTypes.cs index 6ab94889797..21e1718beb4 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.OwnedTypes.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.OwnedTypes.cs @@ -1978,5 +1978,103 @@ public virtual void Shared_type_used_as_owned_type_throws_for_same_name() () => b.OwnsMany("Shared1", e => e.Collection)).Message); }); } + + [ConditionalFact] + public virtual void PrimitiveCollectionBuilder_methods_can_be_chained() + => CreateModelBuilder() + .Entity() + .OwnsOne(e => e.CollectionQuarks) + .PrimitiveCollection(e => e.Up) + .ElementType(t => t + .HasAnnotation("B", "C") + .HasConversion(typeof(long)) + .HasConversion(new CastingConverter()) + .HasConversion(typeof(long), typeof(CustomValueComparer)) + .HasConversion(typeof(long), new CustomValueComparer()) + .HasConversion(new CastingConverter()) + .HasConversion(new CastingConverter(), new CustomValueComparer()) + .HasConversion() + .HasConversion(new CustomValueComparer()) + .HasConversion>() + .HasMaxLength(2) + .HasPrecision(1) + .HasPrecision(1, 2) + .IsRequired() + .IsUnicode()) + .IsRequired() + .HasAnnotation("A", "V") + .IsConcurrencyToken() + .ValueGeneratedNever() + .ValueGeneratedOnAdd() + .ValueGeneratedOnAddOrUpdate() + .ValueGeneratedOnUpdate() + .IsUnicode() + .HasMaxLength(100) + .HasSentinel(null) + .HasValueGenerator() + .HasValueGenerator(typeof(CustomValueGenerator)) + .HasValueGeneratorFactory() + .HasValueGeneratorFactory(typeof(CustomValueGeneratorFactory)) + .IsRequired(); + + [ConditionalFact] + public virtual void PrimitiveCollectionBuilder_methods_can_be_chained_on_collection() + => CreateModelBuilder() + .Entity() + .OwnsMany(e => e.Orders) + .PrimitiveCollection>("List") + .ElementType(t => t + .HasAnnotation("B", "C") + .HasConversion(typeof(long)) + .HasConversion(new CastingConverter()) + .HasConversion(typeof(long), typeof(CustomValueComparer)) + .HasConversion(typeof(long), new CustomValueComparer()) + .HasConversion(new CastingConverter()) + .HasConversion(new CastingConverter(), new CustomValueComparer()) + .HasConversion() + .HasConversion(new CustomValueComparer()) + .HasConversion>() + .HasMaxLength(2) + .HasPrecision(1) + .HasPrecision(1, 2) + .IsRequired() + .IsUnicode()) + .IsRequired() + .HasAnnotation("A", "V") + .IsConcurrencyToken() + .ValueGeneratedNever() + .ValueGeneratedOnAdd() + .ValueGeneratedOnAddOrUpdate() + .ValueGeneratedOnUpdate() + .IsUnicode() + .HasMaxLength(100) + .HasSentinel(null) + .HasValueGenerator() + .HasValueGenerator(typeof(CustomValueGenerator)) + .HasValueGeneratorFactory() + .HasValueGeneratorFactory(typeof(CustomValueGeneratorFactory)) + .IsRequired(); + + private class CustomValueGenerator : ValueGenerator + { + public override int Next(EntityEntry entry) + => throw new NotImplementedException(); + + public override bool GeneratesTemporaryValues + => false; + } + + private class CustomValueGeneratorFactory : ValueGeneratorFactory + { + public override ValueGenerator Create(IProperty property, ITypeBase entityType) + => new CustomValueGenerator(); + } + private class CustomValueComparer : ValueComparer + { + public CustomValueComparer() + : base(false) + { + } + } } } diff --git a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.cs b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.cs index eba48f0445a..03ff8c863a6 100644 --- a/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.cs +++ b/test/EFCore.Specification.Tests/ModelBuilding/ModelBuilderTest.cs @@ -485,10 +485,9 @@ public abstract TestPropertyBuilder HasConversion { + public abstract IMutableProperty Metadata { get; } public abstract TestElementTypeBuilder ElementType(); public abstract TestPrimitiveCollectionBuilder ElementType(Action builderAction); - - public abstract IMutableProperty Metadata { get; } public abstract TestPrimitiveCollectionBuilder HasAnnotation(string annotation, object? value); public abstract TestPrimitiveCollectionBuilder IsRequired(bool isRequired = true); public abstract TestPrimitiveCollectionBuilder HasMaxLength(int maxLength); @@ -652,6 +651,8 @@ public abstract TestComplexTypePropertyBuilder HasConversion { public abstract IMutableProperty Metadata { get; } + public abstract TestElementTypeBuilder ElementType(); + public abstract TestComplexTypePrimitiveCollectionBuilder ElementType(Action builderAction); public abstract TestComplexTypePrimitiveCollectionBuilder HasAnnotation(string annotation, object? value); public abstract TestComplexTypePrimitiveCollectionBuilder IsRequired(bool isRequired = true); public abstract TestComplexTypePrimitiveCollectionBuilder HasMaxLength(int maxLength); @@ -908,6 +909,11 @@ public abstract TestOwnedNavigationBuilder HasAnnotat public abstract TestPropertyBuilder Property( Expression> propertyExpression); + public abstract TestPrimitiveCollectionBuilder PrimitiveCollection(string propertyName); + + public abstract TestPrimitiveCollectionBuilder PrimitiveCollection( + Expression> propertyExpression); + public abstract TestNavigationBuilder Navigation( Expression> navigationExpression) where TNavigation : class;