Commit Graph

316 Commits

Author SHA1 Message Date
Jon Skeet 304bc0602b Implement underscore prefixes for AMQP
The [binding
specification](https://github.com/cloudevents/spec/blob/main/cloudevents/bindings/amqp-protocol-binding.md)
has changed to prefer `cloudEvents_` over `cloudEvents:`. Previously
`cloudEvents_` wouldn't even have been valid.

With this change, users can either:

- Stick with the default prefix, which doesn't change immediately,
  but which will change in the first release on or after March 1st 2023
- Explicitly use one or other prefix using the explicitly-named
  methods

Other options considered:

- Changing the default now: that's too much of a breaking change. (I
  don't want to take a major version bump for this, and with enough
  time for the change, I think that's okay.)
- Adding a char or string parameter: that would invite using non-standard prefixes
- Adding a Boolean parameter: that would become problematic if we
  ever end up with a third prefix. (Let's hope we don't, but still...)
- Adding an enum and then a parameter for it: feels like overkill

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-09-07 21:58:26 +01:00
Magne Helleborg 81c82e04c6
feat: Allow empty payloads in Kafka, in order to support compaction tombstones (#224)
Signed-off-by: Magne Helleborg <magne.helleborg@gmail.com>
2022-08-30 09:18:51 +01:00
Jon Skeet d9e10ead4f Implement public JsonElement conversions in JsonEventFormatter
The method names are consistent with the ones in
ProtobufEventFormatter and the Json.NET event formatter.

Currently batch conversion is not supported, but we can add that later if requested.

The ConvertToJsonElement method is horribly inefficient at the
moment (serialize then parse); we can consider how to make it more
efficient later if necessary.

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-08-18 20:50:26 +01:00
Jon Skeet afaf830ac5 Implement public JObject conversions in JsonEventFormatter
The method names are consistent with the ones in ProtobufEventFormatter.
Currently batch conversion is not supported, but we can add that later if requested.

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-08-18 20:50:26 +01:00
Jon Skeet aa7429d7f7 fix: Observe JsonSerializer options for JsonEventFormatter using Newtonsoft.Json
This is the Json.NET equivalent of #225.

Note that not every option in JsonTextWriter is supported; in the future we could potentially introduce some alternative approach to provide more flexibility.

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-08-05 07:38:52 +01:00
Jon Skeet b67ac2b556 fix: Observe serialization options in JsonEventFormatter for System.Text.Json
Fixes #225

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-08-05 07:38:52 +01:00
Jon Skeet 0005fc71de Update test package dependencies
Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-08-05 07:38:35 +01:00
Jon Skeet 72be5ff000 fix: Put AvroEventFormatter in the right namespace
We still need it in CloudNative.CloudEvents for backward
compatibility, but we can do that via derivation - which is
pleasantly simple given that the only constructor is parameterless.

Users should update to use the CloudNative.CloudEvents.Avro
namespace at their earliest convenience.

Fixes #219.

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-07-26 18:30:29 +01:00
Jon Skeet 8783914863 fix: Perform release builds with ContinuousIntegrationBuild=true
(The build needs to be done this way, not just the packing.)

Fixes #175

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-07-26 18:04:05 +01:00
Jon Skeet 39b691c24a fix: Use content headers when parsing HTTP requests/responses
Fixes #221

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-07-26 18:03:48 +01:00
Jon Skeet 3ce4aa08f2 Release 2.3.1
Changes since 2.3.0:

- Bug fix: ignore the charset when determining the content type for decoding JSON (#216)
- Bug fix: make the NuGet package deterministic (#175)

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-06-29 08:14:13 +01:00
Jon Skeet f74d383c18 fix: Use just the media type to detect JSON, not whole datacontenttype
Fixes #216

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-06-29 07:53:49 +01:00
Jon Skeet ee9d91a398 chore: Tweaks to the sample HttpSend code
In particular, this now generates a random event ID - v1.x used to
do this automatically, but in 2.x it needs to be explicit.

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-06-27 15:53:31 +01:00
Simon Eßlinger e517ee4755 ci(nuget): make dotnet pack deterministic
by adding the flag `-p:ContinuousIntegrationBuild=true`

Signed-off-by: Simon Eßlinger <github@esslinger.dev>
2022-06-24 07:46:19 +01:00
Alexander Batishchev 145486d331 Fixed link to JsonEventFormatter
Signed-off-by: Alexander Batishchev <abatishchev@gmail.com>
2022-06-07 20:22:53 +01:00
Jon Skeet e6f2c4d634 Release 2.3.0
Changes since 2.2.0:

- Bug fix: BinaryDataUtilities.AsArray misbehavior with array segments ([#209](https://github.com/cloudevents/sdk-csharp/issues/209))
- Bug fix: Links within XML documentation corrected after spec repo change
- Feature: Reject "data" as a context attribute name (spec has been clarified for this)
- Feature: Support Data content type inference in event formatters
  - The JsonEventFormatter classes infer "application/json" for all data
- Feature: CloudNative.CloudEvents.Protobuf is now GA (same version as other packages)

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-05-31 18:25:41 +01:00
Jon Skeet 92dd95a1b2 docs: Fix spec references in docs
Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-05-31 18:25:41 +01:00
Jon Skeet 0c1a42e868 fix: Handle array segments correctly
Fixes #209

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-05-30 20:12:45 +01:00
Jon Skeet 8f75a9b3cb fix: Fix CI from the master to main change
docs: Update links to refer to main branch in the spec repo (and others)

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-04-08 19:00:03 +01:00
Jon Skeet 1d077d4e57 docs: Initial docs for contributing and the maintainer list
The contribution guide is largely copied from
https://github.com/cloudevents/sdk-java/blob/master/CONTRIBUTING.md
with suitable changes.

Fixes #204

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-04-07 06:38:13 +01:00
Jon Skeet b1f29cf25b Support data content type inference
- New methods in CloudEventFormatter to support inference
- JsonEventFormatter infers a content type of application/json for non-binary data
- All transports use the inferred content type when formatting in binary mode
- Documentation for both formatters and bindings has been updated

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-02-25 07:11:13 +00:00
Jon Skeet 8d3da7d1e8 Reject "data" as the name of an extension attribute
This isn't currently in the CloudEvents spec, but was agreed at
the meeting of 2022-02-03, on the grounds that the most prominent
event formt - JSON - already *implicitly* prohibits it.

We should wait until the spec is updated before merging this.

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-02-23 16:22:59 +00:00
Jon Skeet 409982e9e9 Release 2.2.0 (with Protobuf 2.0.0-beta.1)
Changes in this release:

- Bug fix: the "source" attribute is now validated to be non-empty
- Bug fix: the JSON event formatters comply with the clarified JSON event format spec
- Dependency: Apache.Avro dependency updated to 1.11.0
- Feature: New package CloudNative.CloudEvents.Protobuf, released as 2.0.0-beta.1

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-02-02 07:26:07 +00:00
Jon Skeet 0349eeb274 feat: Add a Protobuf event formatter
Further features may be added later, e.g. convenience methods.

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-02-01 09:44:35 +00:00
Jon Skeet bf27ac4be3 fix: Validate that source is non-empty
URI references can be empty - we have a test proving that. But the source attribute is required to be non-empty, so we should validate that.

This bug fix is a breaking change for anyone who was previously creating (and then validating) CloudEvent instances with a present-but-empty source.
However, their events were already broken, and we'd expect them to cause issues with other consumers (at least any performing comprehensive validation).

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-02-01 09:44:35 +00:00
Jon Skeet c4a938c24c fix: Minor tweaks to the System.Text.Json JsonEventFormatter for compliance
- Make "JSON media type detection" configurable, and default to */json and */*+json
- Default to JSON content type (including making it present in the serialized event)
- Make a "binary vs non-binary" distinction as the first part of serialization (instead of as a fallback)
- Deserialize string data values regardless of content type
- Prohibit non-string data values for non-JSON content types

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-01-20 07:29:29 +00:00
Jon Skeet d61aa171d1 Replace AppVeyor badge with GitHub Actions one
Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-01-19 16:49:28 +00:00
Jon Skeet 9cf04dc4ba fix: Minor tweaks to the Json.NET JsonEventFormatter for compliance
- Make "JSON media type detection" configurable, and default to */json and */*+json
- Default to JSON content type (including making it present in the serialized event)
- Make a "binary vs non-binary" distinction as the first part of serialization (instead of as a fallback)
- Deserialize string data values regardless of content type
- Prohibit non-string data values for non-JSON content types

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-01-19 08:30:29 +00:00
Jon Skeet 4f13307d66 Update to .NET 6 SDK to build and netcoreapp3.1 for test
This requires a few nullable-reference-type overrides in tests where
we're absolutely confident they won't be null (and if we're wrong,
an NRE is fine to break the test).

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-01-12 07:09:02 +00:00
Jon Skeet 16fb2a24c9 Remove AppVeyor configuration
We're fine with GitHub actions, and there's no real benefit in
having both CI environments.

Signed-off-by: Jon Skeet <jonskeet@google.com>
2022-01-12 07:09:02 +00:00
dependabot[bot] 34dd366d6f Bump Apache.Avro in /src/CloudNative.CloudEvents.Avro
Bumps [Apache.Avro](https://github.com/apache/avro) from 1.10.2 to 1.11.0.
- [Release notes](https://github.com/apache/avro/releases)
- [Commits](https://github.com/apache/avro/compare/release-1.10.2...release-1.11.0)

---
updated-dependencies:
- dependency-name: Apache.Avro
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-11 09:31:09 +00:00
Jon Skeet 42b723d844 docs: Update one sample to show a relative URI for Source
(We want to make it clear that Source can be relative or absolute.)

Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-08-06 11:04:18 +01:00
Ofir Shapira 8e914a3599 Update guide.md
Signed-off-by: Ofir Shapira <ofir.shapira@como.com>
2021-08-05 12:49:46 +01:00
Jon Skeet 33d1d21370 All packages release 2.1.1
Bug fix ([#77](https://github.com/cloudevents/sdk-csharp/pull/177)): dependency on the
`Nullable` package was not declared with `PrivateAssets=all`,
leading to that showing up as a dependency. This would break users
who explicitly have a dependency on an older version of `Nullable`.

This fix shouldn't break anyone, as far as we're aware.

Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-07-21 07:45:03 +01:00
iron9light 10114fb707 "Nullable" package should be added as a development dependency
Signed-off-by: iron9light <iron9light@gmail.com>
2021-07-20 08:07:41 +01:00
Jon Skeet bedad89613 All packages release version 2.1.0
New features:

- Nullable reference type annotations ([#170](https://github.com/cloudevents/sdk-csharp/issues/170))
- More batch support for HttpListener ([#166](https://github.com/cloudevents/sdk-csharp/issues/166))
- CloudEvent.CopyToHttpResponse extension method (part of [#148](https://github.com/cloudevents/sdk-csharp/issues/148))

Other improvements:

- More informative error message for non-CE HTTP requests ([#165](https://github.com/cloudevents/sdk-csharp/issues/165))

Bug fixes:

- Various small XML docs typos ([commit](626089ea1e))
- Don't set the content type to JSON in HttpListener when it's not set in the CloudEvent ([commit](18e13635fe))

Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-07-14 18:52:56 +01:00
Jon Skeet e7ebdd7c1c Enable nullable reference types for unit test project
Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-07-10 07:03:43 +01:00
Jon Skeet bb8f4a8d13 Enable nullable reference types for System.Text.Json formatter
Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-07-10 07:03:43 +01:00
Jon Skeet 1c017d30f4 Enable nullable reference types for Json.NET formatter
Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-07-10 07:03:43 +01:00
Jon Skeet 135232a27c Enable nullable reference types for MQTT
Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-07-10 07:03:43 +01:00
Jon Skeet 0d8a7288fd Enable nullable reference types for Kafka
Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-07-10 07:03:43 +01:00
Jon Skeet 9a76e2c16a Enable nullable reference types for Avro
Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-07-10 07:03:43 +01:00
Jon Skeet 56394bd200 Enable nullable reference types for ASP.NET Core
Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-07-10 07:03:43 +01:00
Jon Skeet 6fedcec3de Enable nullable reference types for AMQP
Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-07-10 07:03:43 +01:00
Jon Skeet 8f43ba1038 Enable nullable reference types for CloudNative.CloudEvents
Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-07-10 07:03:43 +01:00
Jon Skeet 767b0d2acb Add a netstandard2.1 target framework to all production projects
We probably only need it in the Core project to start with, but it feels best to be consistent.
We probably want this regardless of the rest of the PR for nullability.

Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-07-10 07:03:43 +01:00
Jon Skeet 7fba373167 Adjust documented processes based on expectations of releases.
(Maintaining separate package versions now feels like it would be
really awkward, with limited benefit and even some downsides.)

Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-07-10 07:03:22 +01:00
Jon Skeet d4ff2b596e Add methods to copy CloudEvents to HttpResponse
One part of #148

Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-06-30 07:44:33 +01:00
Jon Skeet 2554006b23 Add ToCloudEventBatch to HttpListenerExtensions
Fixes #166

Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-06-30 07:44:33 +01:00
Jon Skeet 626089ea1e Fix XML documentation for existing ToCloudEventBatch methods
Signed-off-by: Jon Skeet <jonskeet@google.com>
2021-06-30 07:44:33 +01:00