This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"description": "Customizes AOT source generation of formatters for custom types.",
"additionalProperties": false,
"properties": {
"usesMapMode": {
"type": "boolean",
"description": "A value indicating whether types will be serialized with their property names as well as their values in a key=value dictionary, as opposed to an array of values.",
"default": false
},
"resolver": {
"type": "object",
"description": "Describes the generated resolver.",
"additionalProperties": false,
"properties": {
"public": {
"type": "boolean",
"description": "A value indicating whether the generated resolver should be public (as opposed to internal). A public resolver is appropriate when developing a library that may be used by another assembly that needs to aggregate this generated resolver with others.",
"default": false
},
"name": {
"type": "string",
"description": "The name to use for the resolver.",
"default": "GeneratedMessagePackResolver"
},
"namespace": {
"type": "string",
"description": "The namespace the source generated resolver will be emitted into.",
"default": "MessagePack"
}
}
},
"formatters": {
"type": "object",
"description": "Customizes aspects of source generated formatters.",
"additionalProperties": false,
"properties": {
"namespace": {
"type": "string",
"description": "The root namespace into which formatters are emitted.",
"default": "Formatters"
}
}
}
}
},
"customFormattedTypes": {
"type": "array",
"description": "An array of fully-qualified names of types that are included in serialized object graphs but are assumed to have custom formatters registered already.",
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you want to allow a specific custom type (for example, when registering a custom type), put `MessagePackAnalyzer.json` at the project root and change the Build Action to `AdditionalFiles`.
@@ -1626,26 +1631,35 @@ T after = MessagePackSerializer.Deserialize<T>(serialized);
### Customizations
A few MSBuild properties can be set in your project to customize source generation:
You can customize the generated source through a `MessagePackAnalyzer.json` file added to the project root directory.
If using Unity, you should configure Unity to treat this as an `AdditionalFiles` in the C# compiler.
Property | Purpose | Default value
--|--|--
`PublicMessagePackGeneratedResolver` | A boolean value indicating whether the generated resolver should be `public`. This is useful for shared libraries so their consumers can leverage the AOT formatters (which are always `internal`) in the library. | `false`
`MessagePackGeneratedResolverNamespace` | The namespace to use for the generated resolver class. | The `$(RootNamespace)` of the project, or `MessagePack` if the root namespace is empty.
`MessagePackGeneratedResolverName` | The name of the generated resolver type. | `GeneratedMessagePackResolver`
`MessagePackGeneratedUsesMapMode` | A boolean value that indicates whether all formatters should use property maps instead of more compact arrays. | `false`
For example you could add this xml to your project file to set each of the above properties (in this example, to their default values):
You can discover all the available settings, their defaults and meanings in a JSON editor that supports JSON schema, or by reviewing [the JSON schema][AnalyzerJsonSchema] yourself.
When exposing the generated resolver publicly, consumers outside the library should aggregate the resolver using its `Instance` property, which contains *only* the generated formatters.
The `InstanceWithStandardAotResolver` property is a convenience for callers that will not be aggregating the resolver with those from other libraries, since it aggregates built-in AOT friendly resolvers from the MessagePack library itself.
Expand Down
Expand Up
@@ -1702,3 +1716,5 @@ The StreamJsonRpc library is based on [JSON-RPC](https://www.jsonrpc.org/) and i
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switch from MSBuild properties to an AdditionalFiles json file #1667
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Switch from MSBuild properties to an AdditionalFiles json file #1667
Filter by extension
Only manifest files
Deleted files Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Uh oh!
There was an error while loading. Please reload this page.