Improve test naming, add comprehensive documentation, and introduce JsonDateTimeFormatAttribute#1
Conversation
Co-authored-by: ScarletKuro <19953225+ScarletKuro@users.noreply.github.com>
Co-authored-by: ScarletKuro <19953225+ScarletKuro@users.noreply.github.com>
Co-authored-by: ScarletKuro <19953225+ScarletKuro@users.noreply.github.com>
|
That line you added: Is not very accurate, the Also add unit test if I'm missing some cases. And seems |
…t file Co-authored-by: ScarletKuro <19953225+ScarletKuro@users.noreply.github.com>
Fixed in commit ed07f04:
All 15 tests now pass. |
|
@copilot we might need to create a new dedicated attribute for Because |
… source generators Co-authored-by: ScarletKuro <19953225+ScarletKuro@users.noreply.github.com>
... Fixed in commit 3b44e3e: Created Key changes:
Result: Users can now choose |
Task: Improve test naming, update documentation, and eliminate SYSLIB1223 warnings
Completed Work
✅ Test Improvements
Improved test method names - Changed from verbose names to concise, descriptive names focusing on key aspects:
ReflectionBased_DateTime_WithAttribute,SourceGenerator_CompleteModel_WithFormatConverter,SourceGenerator_WithResolver_WithAttribute_UsingOptionsRenamed test model classes for better clarity:
TestModelJsonDateTimeConverter→ReflectionBasedModelTestModelSourceGenerator→SourceGeneratorWithConverterModelTestModelSourceGeneratorAttributes→SourceGeneratorWithResolverAttributeModelSourceGeneratorWithResolverFormatModel(uses new attribute, no warnings)Added XML documentation to all test model classes explaining their purpose and usage scenarios
Moved resolver tests to correct location - Moved
SourceGenerator_WithResolver_WithAttribute_UsingOptionsandSourceGenerator_WithResolver_WithAttribute_UsingContextfromJsonDateTimeFormatConverterTests.cstoJsonDateTimeConverterAttributeTests.cssince they test attributes, not convertersSplit test contexts - Created separate
ConverterModelJsonSerializerContextandResolverModelJsonSerializerContextfor better organizationAdded comprehensive test coverage - Added 3 new tests for
JsonDateTimeFormatAttribute(16 total tests)✅ New Feature: JsonDateTimeFormatAttribute
JsonDateTimeFormatAttribute- A clean attribute that derives fromAttribute(notJsonConverterAttribute) specifically for use with .NET 9+ source generators andDateTimeConverterResolverJsonDateTimeConverterAttributewhich produces 4 warningsDateTimeConverterResolver- Now intelligently supports bothJsonDateTimeFormatAttribute(recommended, no warnings) andJsonDateTimeConverterAttribute(backward compatibility, has warnings)JsonDateTimeFormatAttributefor new codeJsonDateTimeConverterAttributefor existing code or reflection-based scenarios✅ Documentation
Completely reconstructed README.md with:
JsonPropertyInfo.AttributeProviderexists in .NET 7-8, but source generators don't populate it until .NET 9+ (with references to GitHub issues runtime#100095 and runtime#102078)Created AGENT.md with:
Verification
JsonDateTimeFormatAttribute)JsonDateTimeConverterAttribute, kept for backward compatibility testing)Summary
This PR provides a complete solution for warning-free source generator usage while maintaining backward compatibility. Users can now choose
JsonDateTimeFormatAttributefor clean, modern development or continue usingJsonDateTimeConverterAttributefor existing code.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.