parent
3eb3a0dec4
commit
6e15c83e1a
|
@ -20,6 +20,9 @@ CHANGELOG
|
|||
- Add support for enabling Policy Packs with configuration.
|
||||
[#3756](https://github.com/pulumi/pulumi/pull/4127)
|
||||
|
||||
- Remove obsolete .NET serialization attributes.
|
||||
[#4190](https://github.com/pulumi/pulumi/pull/4190)
|
||||
|
||||
## 1.13.0 (2020-03-18)
|
||||
- Add support for plugin acquisition for Go programs
|
||||
[#4060](https://github.com/pulumi/pulumi/pull/4060)
|
||||
|
|
|
@ -172,15 +172,6 @@ Pulumi.ResourceTransformationResult
|
|||
Pulumi.ResourceTransformationResult.Args.get -> Pulumi.ResourceArgs
|
||||
Pulumi.ResourceTransformationResult.Options.get -> Pulumi.ResourceOptions
|
||||
Pulumi.ResourceTransformationResult.ResourceTransformationResult(Pulumi.ResourceArgs args, Pulumi.ResourceOptions options) -> void
|
||||
Pulumi.Serialization.InputAttribute
|
||||
Pulumi.Serialization.InputAttribute.InputAttribute(string name, bool required = false, bool json = false) -> void
|
||||
Pulumi.Serialization.OutputAttribute
|
||||
Pulumi.Serialization.OutputAttribute.Name.get -> string
|
||||
Pulumi.Serialization.OutputAttribute.OutputAttribute(string name = null) -> void
|
||||
Pulumi.Serialization.OutputConstructorAttribute
|
||||
Pulumi.Serialization.OutputConstructorAttribute.OutputConstructorAttribute() -> void
|
||||
Pulumi.Serialization.OutputTypeAttribute
|
||||
Pulumi.Serialization.OutputTypeAttribute.OutputTypeAttribute() -> void
|
||||
Pulumi.Stack
|
||||
Pulumi.Stack.Stack(Pulumi.StackOptions options = null) -> void
|
||||
Pulumi.StackOptions
|
||||
|
|
|
@ -23,22 +23,14 @@ namespace Pulumi
|
|||
{
|
||||
var fieldQuery =
|
||||
from field in this.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)
|
||||
let attr1 = field.GetCustomAttribute<Pulumi.InputAttribute>()
|
||||
#pragma warning disable 618
|
||||
let attr2 = field.GetCustomAttribute<Pulumi.Serialization.InputAttribute>()
|
||||
#pragma warning restore 618
|
||||
where attr1 != null || attr2 != null
|
||||
let attr = attr1 ?? new Pulumi.InputAttribute(attr2.Name, attr2.IsRequired, attr2.Json)
|
||||
let attr = field.GetCustomAttribute<InputAttribute>()
|
||||
where attr != null
|
||||
select (attr, memberName: field.Name, memberType: field.FieldType, getValue: (Func<object, object?>)field.GetValue);
|
||||
|
||||
var propQuery =
|
||||
from prop in this.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)
|
||||
let attr1 = prop.GetCustomAttribute<Pulumi.InputAttribute>()
|
||||
#pragma warning disable 618
|
||||
let attr2 = prop.GetCustomAttribute<Pulumi.Serialization.InputAttribute>()
|
||||
#pragma warning restore 618
|
||||
where attr1 != null || attr2 != null
|
||||
let attr = attr1 ?? new Pulumi.InputAttribute(attr2.Name, attr2.IsRequired, attr2.Json)
|
||||
let attr = prop.GetCustomAttribute<InputAttribute>()
|
||||
where attr != null
|
||||
select (attr, memberName: prop.Name, memberType: prop.PropertyType, getValue: (Func<object, object?>)prop.GetValue);
|
||||
|
||||
var all = fieldQuery.Concat(propQuery).ToList();
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
// Copyright 2016-2019, Pulumi Corporation
|
||||
|
||||
using System;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
namespace Pulumi.Serialization
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute used by a Pulumi Cloud Provider Package to mark Resource output properties.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
[Obsolete("Use Pulumi.OutputAttribute instead")]
|
||||
public sealed class OutputAttribute : Attribute
|
||||
{
|
||||
public string? Name { get; }
|
||||
|
||||
public OutputAttribute(string? name = null)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attribute used by a Pulumi Cloud Provider Package to mark Resource input fields and
|
||||
/// properties.
|
||||
/// <para/>
|
||||
/// Note: for simple inputs (i.e. <see cref="Input{T}"/> this should just be placed on the
|
||||
/// property itself. i.e. <c>[Input] Input<string> Acl</c>.
|
||||
///
|
||||
/// For collection inputs (i.e. <see cref="InputList{T}"/> this should be placed on the
|
||||
/// backing field for the property. i.e.
|
||||
///
|
||||
/// <code>
|
||||
/// [Input] private InputList<string> _acls;
|
||||
/// public InputList<string> Acls
|
||||
/// {
|
||||
/// get => _acls ?? (_acls = new InputList<string>());
|
||||
/// set => _acls = value;
|
||||
/// }
|
||||
/// </code>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
[Obsolete("Use Pulumi.InputAttribute instead")]
|
||||
public sealed class InputAttribute : Attribute
|
||||
{
|
||||
internal string Name { get; }
|
||||
internal bool IsRequired { get; }
|
||||
internal bool Json { get; }
|
||||
|
||||
public InputAttribute(string name, bool required = false, bool json = false)
|
||||
{
|
||||
Name = name;
|
||||
IsRequired = required;
|
||||
Json = json;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attribute used by a Pulumi Cloud Provider Package to mark complex types used for a Resource
|
||||
/// output property. A complex type must have a single constructor in it marked with the
|
||||
/// <see cref="OutputConstructorAttribute"/> attribute.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
[Obsolete("Use Pulumi.OutputTypeAttribute instead")]
|
||||
public sealed class OutputTypeAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attribute used by a Pulumi Cloud Provider Package to marks the constructor for a complex
|
||||
/// property type so that it can be instantiated by the Pulumi runtime.
|
||||
///
|
||||
/// The constructor should contain parameters that map to the resultant <see
|
||||
/// cref="Struct.Fields"/> returned by the engine.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Constructor)]
|
||||
[Obsolete("Use Pulumi.OutputConstructorAttribute instead")]
|
||||
public sealed class OutputConstructorAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
|
@ -113,10 +113,7 @@ namespace Pulumi.Serialization
|
|||
$"Unexpected generic target type {targetType.FullName} when deserializing {context}");
|
||||
}
|
||||
|
||||
if (targetType.GetCustomAttribute<Pulumi.OutputTypeAttribute>() == null
|
||||
#pragma warning disable 618
|
||||
&& targetType.GetCustomAttribute<Pulumi.Serialization.OutputTypeAttribute>() == null)
|
||||
#pragma warning restore 618
|
||||
if (targetType.GetCustomAttribute<Pulumi.OutputTypeAttribute>() == null)
|
||||
return (null, new InvalidOperationException(
|
||||
$"Unexpected target type {targetType.FullName} when deserializing {context}"));
|
||||
|
||||
|
@ -377,24 +374,21 @@ $@"{context} contains invalid type {targetType.FullName}:
|
|||
}
|
||||
}
|
||||
|
||||
var propertyTypeAttribute = (Attribute?)targetType.GetCustomAttribute<Pulumi.OutputTypeAttribute>()
|
||||
#pragma warning disable 618
|
||||
?? targetType.GetCustomAttribute<Pulumi.Serialization.OutputTypeAttribute>();
|
||||
#pragma warning restore 618
|
||||
var propertyTypeAttribute = (Attribute?)targetType.GetCustomAttribute<OutputTypeAttribute>();
|
||||
if (propertyTypeAttribute == null)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$@"{context} contains invalid type {targetType.FullName}. Allowed types are:
|
||||
String, Boolean, Int32, Double,
|
||||
Nullable<...>, ImmutableArray<...> and ImmutableDictionary<string, ...> or
|
||||
a class explicitly marked with the [{nameof(Pulumi.OutputTypeAttribute)}].");
|
||||
a class explicitly marked with the [{nameof(OutputTypeAttribute)}].");
|
||||
}
|
||||
|
||||
var constructor = GetPropertyConstructor(targetType);
|
||||
if (constructor == null)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$@"{targetType.FullName} had [{nameof(Pulumi.OutputTypeAttribute)}], but did not contain constructor marked with [{nameof(Pulumi.OutputConstructorAttribute)}].");
|
||||
$@"{targetType.FullName} had [{nameof(OutputTypeAttribute)}], but did not contain constructor marked with [{nameof(OutputConstructorAttribute)}].");
|
||||
}
|
||||
|
||||
foreach (var param in constructor.GetParameters())
|
||||
|
@ -405,9 +399,6 @@ $@"{targetType.FullName} had [{nameof(Pulumi.OutputTypeAttribute)}], but did not
|
|||
|
||||
private static ConstructorInfo GetPropertyConstructor(System.Type outputTypeArg)
|
||||
=> outputTypeArg.GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).FirstOrDefault(
|
||||
c => c.GetCustomAttributes<Pulumi.OutputConstructorAttribute>() != null
|
||||
#pragma warning disable 618
|
||||
|| c.GetCustomAttributes<Pulumi.Serialization.OutputConstructorAttribute>() != null);
|
||||
#pragma warning restore 618
|
||||
c => c.GetCustomAttributes<OutputConstructorAttribute>() != null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,12 +63,9 @@ namespace Pulumi.Serialization
|
|||
var type = resource.GetResourceType();
|
||||
|
||||
var query = from property in resource.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)
|
||||
let attr1 = property.GetCustomAttribute<Pulumi.OutputAttribute>()
|
||||
#pragma warning disable 618
|
||||
let attr2 = property.GetCustomAttribute<Pulumi.Serialization.OutputAttribute>()
|
||||
#pragma warning restore 618
|
||||
where attr1 != null || attr2 != null
|
||||
select (property, attrName: attr1?.Name ?? attr2?.Name);
|
||||
let attr = property.GetCustomAttribute<OutputAttribute>()
|
||||
where attr != null
|
||||
select (property, attrName: attr?.Name);
|
||||
|
||||
var result = ImmutableDictionary.CreateBuilder<string, IOutputCompletionSource>();
|
||||
foreach (var (prop, attrName) in query.ToList())
|
||||
|
|
|
@ -81,12 +81,9 @@ namespace Pulumi
|
|||
internal void RegisterPropertyOutputs()
|
||||
{
|
||||
var outputs = (from property in this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
|
||||
let attr1 = property.GetCustomAttribute<Pulumi.OutputAttribute>()
|
||||
#pragma warning disable 618
|
||||
let attr2 = property.GetCustomAttribute<Pulumi.Serialization.OutputAttribute>()
|
||||
#pragma warning restore 618
|
||||
where attr1 != null || attr2 != null
|
||||
let name = attr1?.Name ?? attr2?.Name ?? property.Name
|
||||
let attr = property.GetCustomAttribute<OutputAttribute>()
|
||||
where attr != null
|
||||
let name = attr?.Name ?? property.Name
|
||||
select new KeyValuePair<string, object?>(name, property.GetValue(this))).ToList();
|
||||
|
||||
// Check that none of the values are null: catch unassigned outputs
|
||||
|
|
Loading…
Reference in a new issue