OData / OData/ODataConnectedService

[T4] Code Generation generates too much code

Open
#243 7 comments 3 reactions 1 assignee View on GitHub

@paulodero is already working on this.

Since Dec 3, 2019.

backlog bug client
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:

  1. The base type actually did something useful, like implement INotifyPropertyChanged and INotifyPropertyChanging.
  2. Custom OnXXXXChanging and OnXXXXChanged functions were removed in favor of INPCing and INPCed.
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.