Fix broken code samples in docs content#520
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the IceRPC documentation to fix a set of compile-breaking and correctness issues in code samples across the Slice, Protobuf, and IceRPC guides, aligning examples with the actual generated C# shapes and public APIs.
Changes:
- Corrects C# sample code to use the right types/identifiers and valid syntax (e.g.,
new Uri(...),ServerAddress = new ServerAddress(...), correct proxy names, missingreturn, missing;). - Aligns Slice language mapping samples with generated output (e.g.,
required ... { get; set; }, correctWellKnownTypes::*names). - Fixes doc-comment cross-references in Slice examples to the established
{@link ...}format.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| content/slice/language-guide/using-proxies-as-slice-types.md | Fixes Slice doc-comment links to use {@link Widget} consistently. |
| content/slice/language-guide/sequence-types.md | Updates C# mapping sample to generated required properties. |
| content/slice/language-guide/result-types.md | Fixes WellKnownTypes casing in the mapping table. |
| content/slice/language-guide/interface.md | Fixes proxy typo and corrects conversion operators to public + improves wording. |
| content/slice/language-guide/fields.md | Corrects WellKnownTypes::Uri reference. |
| content/slice/language-guide/dictionary-types.md | Updates C# mapping sample to generated required properties. |
| content/slice/basics/contract-first.md | Fixes incorrect variable usage (greeter → greeterProxy). |
| content/protobuf/language-mapping/service.md | Adds missing ; to .proto RPC definition. |
| content/protobuf/index.md | Fixes request message type name (GreetRequest). |
| content/icerpc/invocation/service-address.md | Fixes incorrect invoker variable name (connection → clientConnection). |
| content/icerpc/dispatch/incoming-request.md | Fixes API types/usage (IFeatureCollection, Get<T>()). |
| content/icerpc/dispatch/dispatch-pipeline.md | Fixes ServerAddress sample to use the correct wrapper type. |
| content/icerpc/dependency-injection/invocation-pipeline-with-di.md | Fixes missing semicolons in chained DI examples. |
| content/icerpc/dependency-injection/dispatch-pipeline-with-di.md | Fixes missing return in middleware sample to avoid CS0161. |
| content/icerpc/connection/server-address.md | Fixes unterminated interpolated string / formatting error in sample. |
| content/icerpc/connection/security-with-tls.md | Fixes ClientConnection samples to pass Uri instead of string. |
| content/icerpc-for-ice-users/ice-definitions/fields.md | Aligns record struct samples with expected partial declaration. |
| content/icerpc-for-ice-users/ice-definitions/enum-types.md | Fixes enum sample visibility (public enum). |
| content/getting-started/icerpc-protobuf-tutorial/client-tutorial.md | Adds missing request initialization in the client tutorial sample. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Verified every fix against the
The remaining fixes (missing semicolons, unterminated string, identifier typos) are syntax-level. |
pepone
left a comment
There was a problem hiding this comment.
Looks good, we should check the horizontal scroll for the updated code samples, possibly for existing ones too.
| internal readonly partial record struct RectangleProxy : IRectangle, IProxy | ||
| { | ||
| internal static implicit operator ShapeProxy(RectangleProxy proxy) | ||
| public static implicit operator ShapeProxy(RectangleProxy proxy) |
There was a problem hiding this comment.
The default is now internal isn't it? Is the implicit constructor still public?
There was a problem hiding this comment.
The conversion operator itself is still generated as public static implicit — see ProxyGenerator.cs:146 on the 0.6.x branch. C# requires user-defined conversion operators to be declared public (CS0558 otherwise), even inside an internal type; the member's effective accessibility is then capped by the containing type. So public here matches both the language rule and the generated code, while the proxy struct itself stays internal by default.
Fixes 31 defects in code samples across 19 content pages, found during a full editorial review. Every fix was verified against the
0.6.xbranch of icerpc-csharp (examples, templates, and generator sources) — see the verification comment below.Doesn't compile
new ClientConnection("icerpc://…")with a plain string in six samples on the security-with-tls page — no such constructor; wrapped innew Uri(…)ServerAddress = new Uri(…)— the property isServerAddress?→new ServerAddress(new Uri(…))FeatureCollectioninstead ofIFeatureCollection, plusfeatures.Get<T>missing its call parenthesesifbranch with no return in the DI deadline middleware (CS0161)internal static implicit operator— conversion operators must be public (CS0558)Wrong identifiers
greeter→greeterProxy,connection→clientConnection,GreeterRequest→GreetRequest,WidgetPRoxy→WidgetProxy,WellknownTypes/WellKnownType→WellKnownTypesDoesn't match the documented mapping / templates
required … { get; set; }properties (per fields.md)requestwithout defining it — added the template'svar request = new GreetRequest { Name = Environment.UserName };@Widgetdoc-comment links →{@link Widget}public/partialmodifiers in two ice-users samples🤖 Generated with Claude Code