OData / OData/ODataConnectedService
[T4] Code Generation generates too much code
@paulodero is already working on this.
Since Dec 3, 2019.
- Dominant language
- C#
- Stars
- 84
- Forks
- 52
- Avg merge
- 8h 39m
- Merged PRs (30d)
- 7
Description
The T4 code generation template hasn't changed too much since the WCF Data Services days. It has a lot of cruft from before the days of generics, tuples, and such.
- One of those design hold-overs is the fact that every property generates its own OnXXXXChanging and OnXXXXChanged functions.
- Another is that is makes every generated object inherits from a base type that does nothing except provide access to a DataServiceContext that a) isn't used anywhere, and b) gets in the way of real-world usage (#286).
- A third is that the codegen builds "CreateXXXX" functions that just create a new instance of an object and return it, instead of just implementing normal constructors.
This generated code could be simplified quite a bit if:
- The base type actually did something useful, like implement INotifyPropertyChanged and INotifyPropertyChanging.
- Custom OnXXXXChanging and OnXXXXChanged functions were removed in favor of INPCing and INPCed.
- CreateXXXX functions were turned into normal constructors.
Detailed Google and GitHub searches showed that none of these "legacy" features appear to be in use. In the case of BaseEntityType.Context, none of the DataServiceClient code actually USES it besides setting the instance in the AtomMaterializer, which is no longer a supported format anyway.
I am working on a PR for these changes... so far all of the Unit Tests still pass. Will this break anything as far as anyone on the team knows?
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.