- Fixes warning in generated AutoMockable methods that have implicit optional return values
- Support for
optional
methods in ObjC protocols - Support for parsing lazy vars into Variable's attributes.
- Updated Stencil to 0.13.1 and SwiftStencilKit to 2.7.0
- In Swift templates CLI arguments should now be accessed via
argument
instead ofarguments
, to be consistent with Stencil and JS templates. - Now in swift templates you can define types, extensions and use other Swift features that require file scope, without using separate files. All templates code is now placed at the top level of the template executable code, instead of being placed inside an extension of
TemplateContext
type. - Fixed missing generated code annotated with
inline
annotation when corresponding annotation in sources are missing. This generated code will be now present in*.generated.swift
file. - Updated AutoHashable template to use Swift 4.2's
hash(into:)
method fromHashable
, and enable support for inheritance.
- You can now pass a json string as a command line arg or annotation and have it parsed into a Dictionary or Array to be used in the template.
- Support for Xcode 10 and Swift 4.2
- Replace
swiftc
with the Swift Package Manager to build Swift templates
- You can now include entire Swift files in Swift templates
- You can now use AutoEquatable with annotations
- Content from multiple file annotations will now be concatenated instead of writing only the latest generated content.
For example content generated by two following templates
// sourcery:file:Generated/Foo.swift
line one
// sourcery:end
and
// sourcery:file:Generated/Foo.swift
line two
// sourcery:end
will be written to one file:
line one
line two
- Use AnyObject for class-only protocols
- Fixed parsing associated enum cases in Xcode 10
- Fixed AutoEquatable access level for
==
func - Fixed path of generated files when linked to Xcode project
- Fixed extraction of inline annotations in multi line comments with documentation style
- Fixed compile error when used AutoHashable in NSObject subclass.
- Added support for enums in AutoCodable template
- You can now specify the base path for the Sourcery cache directory with a
cacheBasePath
key in the config file
- Added AutoCodable template
- Fixed parsing protocol method return type followed by declaration with attribute
- Fixed inserting auto-inlined code on the last line of declaration body
- AutoEquatable and AutoHashable templates should not add protocol conformances in extensions
- Migrate to Swift 4.1 and Xcode 9.3
- Autocases template not respecting type access level
- Ensure SPM and CocoaPods dependencies match
- Improve AutoMockable template to handle methods with optional return values
- Fixed crash while compiling swift templates
- Do not fail the build if slather fails
- Updated SourceKitten to 0.20.0
- Fixed parsing protocol methods return type (#579)
- Supports adding new templates files while in watcher mode
- Supports adding new source files while in watcher mode
- Added support for subscripts
- Added
isGeneric
property forMethod
- You can now pass additional arguments one by one, i.e.
--args arg1=value1 --args arg2 --args arg3=value3
- Improved support for generic types. Now you can access basic generic type information with
TypeName.generic
property - added
@objcMembers
attribute - Moved EJS and Swift templates to separate framework targets
- EJS templates now can be used when building Sourcery with SPM
- Added Closures to AutoMockable
- You can now link generated files to projects using config file
- You can now use AutoMockable with annotations
- Updated to latest version of Stencil (commit 9184720)
- Added support for annotation namespaces
- Added
--exclude-sources
and--exclude-templates
CLI options
** Breaking **
- @objc attribute now has a
name
argument that contains Objective-C name of attributed declaration - Type collections
types.based
,types.implementing
andtypes.inheriting
now return non-optional array. If no types found, empty array will be returned. This is a breaking change for template code like this:
<% for type in (types.implementing["SomeProtocol"] ?? []) { %>
The new correct syntax would be:
<% for type in types.implementing["SomeProtocol"] { %>
- Migrate to Swift 4, SwiftPM 4 and Xcode 9.2
selectorName
for methods without parameters now will not contain()
returnTypeName
for initializers will be the type name of defining type, with?
for failable initializers- Improved compile time of AutoHashable template
- Updated StencilSwiftKit and Stencil to 0.10.1
- Fixes FSEvents errors reported in #465 that happen on Sierra
- JS exceptions no more override syntax errors in JS templates
- Accessing unknown property on
types
now results in a better error thanundefined is not an object
in JS templates - Fixed issue in AutoMockable, where generated non-optional variables wouldn't meet protocol's requirements. For this purpose, underlying variable was introduced
- Fixed
inline:auto
not inserting code if Sourcery is run with cache enabled #467 - Fixed parsing @objc attributes on types
- Fixed parsing void return type in methods without spaces between method name and body open curly brace and in protocols
- Fixed AutoMockable template generating throwing method with void return type
- Fixed parsing throwing initializers
- Fixed trying to process files which do not exist
- Automockable will not generate mocks for methods defined in protocol extensions
- Fixed parsing typealiases of generic types
- AutoLenses template will create lenses only for stored properties
- Fixed resolving actual type name for generics with inner types
- Fixed parsing nested types from extensions
- Fixed removing back ticks in types names
- Fixed creating output folder if it does not exist
- Fixed inferring variable types with closures and improved inferring types of enum default values
- Fixed enum cases with empty parenthesis not having () associated value
- When installing Sourcery via CocoaPods, the unneeded
file.zip
is not kept inPods/Sourcery/
anymore (freeing ~12MB on each install of Sourcery made via CocoaPods!).
- Added test for count Stencil filter
- Added new reversed Stencil filter
- Added new isEmpty Stencil filter
- Added new sorted and sortedDescending Stencil filters. This can sort arrays by calling e.g.
protocol.allVariables|sorted:"name"
- Added new toArray Stencil filter
- Added a console warning when a yaml is available but any parameter between 'sources', templates', 'forceParse', 'output' are provided
- Add release to Homebrew rake task
- Fixed Swiftlint warnings
- Fixed per file generation if there is long (approx. 150KB) output inside
sourcery:file
annotation - Do not generate default.profraw
- Remove filters in favor of same filters from StencilSwiftKit
- Added support for file paths in
config
parameter - Added
isDeinitializer
property for methods - Improved config file validation and error reporting
- Various improvements for
AutoMockable
template:- support methods with reserved keywords name
- support methods that throws
- improved generated declarations names
- Fixed single file generation not skipping writing the file when there is no generated content
- Updated dependencies for Swift 4
- Update internal ruby dependencies
- Added support in
AutoHashable
for static variables,[Hashable]
array and[Hashable: Hashable]
dictionary - Added
definedInType
property forMethod
andVariable
- Added
extensions
filter for stencil template - Added include support in Swift templates
- Swift templates now can throw errors. You can also throw just string literals.
- Added support for TypeName in string filters (except filters from StencilSwiftKit).
- Fixed linker issue when using Swift templates
- Updated
AutoMockable
to exclude generated code collisions - Fixed parsing of default values for variables that also have a body (e.g. for
didSet
) - Fixed line number display when an error occur while parsing a Swift template
- Fixed
rsync
issue onSourceryRuntime.framework
when using Swift templates - Fixed
auto:inline
for nested types (this concerns the first time the code is inserted)
- Fix link for template in docs
- Fix running Sourcery in the example app
- Add step to update internal boilerplate code during the release
- Add Version.swift to represent CLI tool version
- Fixed regression in parsing templates from config file
- Removed meaningless
isMutating
property forVariable
- Improvements in release script
- Updated boilerplate code to reflect latest changes
- Added
inout
flag forMethodParameter
- Added parsing
mutating
andfinal
attributes with convenienceisMutating
andisFinal
properties - Added support for
include
Stencil tag - Added support for excluded paths
- Fixed inserting generated code inline automatically at wrong position
- Fixed regression in AutoEquatable & AutoHashable template with private computed variables
- Internal release procedure improvements
- Improved
TemplatesTests
scheme running - Fixed swiftlint warnings (version 0.19.0)
- Paths in config file are now relative to config file path by default, absolute paths should start with
/
- Improved logging and error reporting, added
--quiet
CLI option, added runtime errors for using invalid types inimplementing
andinheriting
- Added support for includes in EJS templates (for example:
<%- include('myTemplate.js') %>
) - Add the
lowerFirst
filter for Stencil templates. - Added
isRequired
property forMethod
- Improved parsing of closure types
- Check if Current Project Version match version in podspec in release task
- Improved swift templates performance
- Added
// sourcery:file
annotation for source code
- Fixed detecting computed properties
- Fixed typo in
isConvenienceInitialiser
property - Fixed creating cache folder when cache is disabled
- Fixed parsing multiple enum cases annotations
- Fixed parsing inline annotations when there is an access level or attribute
- Fixed parsing
required
attribute - Fixed typo in
guides/Writing templates.md
- Improved
AutoMockable.stencil
to support protocols withinit
methods - Improved
AutoCases.stencil
to uselet
instead of computedvar
- Updated StencilSwiftKit to 1.0.2 which includes Stencil 0.9.0
- Adding docset to release archive
- Add tests for bundled stencil templates
- Moved to CocoaPods 1.2.1
- Made Array.parallelMap's block non-escaping
- Added some convenience accessors for classic, static and instance methods, and types and contained types grouped by names
- Added support for inline code generation without requiring explicit
// sourcery:inline
comments in the source files. To use, usesourcery:inline:auto
in a template:// sourcery:inline:auto:MyType.TemplateName
- Added
isMutable
property forVariable
- Added support for scanning multiple targets
- Added access level filters and disabled filtering private declarations
- Added support for inline comments for annotations with
/*
and*/
- Added annotations for enum case associated values and method parameters
- Added
isConvenienceInitializer
property forMethod
- Added
defaultValue
for variables and method parameters - Added docs generated with jazzy
- Sourcery now will not create empty files and will remove existing generated files with empty content if CLI flag
prune
is set totrue
(false
by default) - Sourcery now will remove inline annotation comments from generated code.
- Added
rethrows
property toMethod
- Allow duplicated annotations to be agregated into array
- Added ejs-style tags to control whitespaces and new lines in swift templates
- Added CLI option to provide path to config file
- Inserting multiple inline code block in one file
- Suppress warnings when compiling swift templates
- Accessing protocols in Swift templates
- Crash that would happen sometimes when parsing typealiases
- Replaced
TypeReflectionBox
andGenerationContext
types with commonTemplateContext
.
- Added flag to check if
TypeName
is dictionary - Added support for multiple sources and templates paths, sources, templates and output paths now should be provided with
--sources
,--templates
and--output
options - Added support for YAML file configuration
- Added generation of non-swift files using
sourcery:file
annotation
- Fixed observing swift and js templates
- Fixed parsing generic array types
- Fixed using dictionary in annotations
- Added parsing array types
- Added support for JavaScript templates (using EJS)
- Fixed escaping variables with reserved names
- Fixed duplicated methods and variables in
allMethods
andallVariables
- Fixed trimming attributes in type names
- Cache initial file contents, including the inline generated ranges so that they are always up to date
- Added per file code generation
- Fixed parsing annotations with complex content
- Fixed inline parser using wrong caching logic
- Sourcery will no longer write files if content didn't change, this improves behaviour of things depending on modification date like Xcode, Swiftlint.
- Improved support for contained types
- Fixes cache handling that got broken in 0.5.4
- Added inline code generation
- Added
isClosure
property toTypeName
to detect closure types
- Fixed parsing of associated values separater by newlines
- Fixed preserving order of inherited types
- Improved support for throwing methods in protocols
- Fixed extracting parameters of methods with closures in their bodies
- Fixed extracting method return types of tuple types
- Improved support for typealises as tuple elements types
- Method parameters with
_
argument label will now havenil
inargumentLabel
property - Improved support for generic methods
- Improved support for contained types
- adjusted internal templates and updated generated code
- moved methods parsing related tests in a separate spec
- Added support for method return types with
throws
andrethrows
- Added a new filter
replace
. Usage:{{ name|replace:"substring","replacement" }}
- replaces occurrences ofsubstring
withreplacement
inname
(case sensitive) - Improved support for inferring types of variables with initial values
- Sourcery is now bundling a set of example templates, you can access them in Templates folder.
- We now use parallel parsing and cache source artifacts. This leads to massive performance improvements:
- e.g. on big codebase of over 300 swift files:
Sourcery 0.5.2
Processing time 8.69941002130508 seconds
Sourcery 0.5.3
First time 4.69904798269272 seconds
Subsequent time: 0.882099032402039 seconds
- Method
accessLevel
was not exposed as string so not accessible properly via templates, fixed that. - Fixes on Swift Templates
-
Added support for
ImplicitlyUnwrappedOptional
-
actualTypeName
property ofMethod.Parameter
,Variable
,Enum.Case.AssociatedValue
,TupleType.Element
now returnstypeName
if type is not a type alias -
Enum
now contains type information for its raw value type.rawType
now returnType
object,rawTypeName
returns itsTypeName
-
Added
annotated
filter to filter by annotations -
Added negative filters counterparts
-
Added support for attributes, i.e.
@escaping
-
Experimental support for Swift Templates
-
Swift Templates are now supported
<% for type in types.classes { %>
extension <%= type.name %>: Equatable {}
<% if type.annotations["showComment"] != nil { %> // <%= type.name %> has Annotations <% } %>
func == (lhs: <%= type.name %>, rhs: <%= type.name %>) -> Bool {
<% for variable in type.variables { %> if lhs.<%= variable.name %> != rhs.<%= variable.name %> { return false }
<% } %>
return true
}
<% } %>
- Variables with default initializer are now supported, e.g.
var variable = Type(...)
- Added support for special escaped names in enum cases e.g.
default
orfor
- Added support for tuple types and
tuple
filter for variables - Enum associated values now have
localName
andexternalName
properties. - Added
actualTypeName
forTypeName
that is typealias - Added
implements
,inherits
andbased
filters
- Using protocols doesn't expose variables using KVC, which meant some of the typeName properties weren't accessible via Templates, we fixed that using Sourcery itself to generate specific functions.
- Fixed parsing typealiases for tuples and closure types
- Fixed parsing associated values of generic types
- Performed significant refactoring and simplified mutations in parsers
- You can now pass arbitrary values to templates with
--args
argument. - Added
open
access level - Type
inherits
andimplements
now allow you to access full type information, not just name - Type
allVariables
will now include all variables, including those inherited from supertype and known protocols. - Type
allMethods
will now include all methods, including those inherited from supertype and known protocols. - AssociatedValue exposes
unwrappedTypeName
,isOptional
- New Available stencil filters:
static
,instance
,computed
,stored
for Variablesenum
,class
,struct
,protocol
for Typesclass
,initializer
,static
,instance
for Methodscount
for Arrays, this is used when chaining arrays with filters where Stencil wouldn't allow us to do.count
, e.g.{{ variables|instance|count }}
- Now you can avoid inferring unknown protocols as enum raw types by adding conformance in extension (instead of
enum Foo: Equatable {}
doenum Foo {}; extension Foo: Equatable {}
)
- Refactor code around typenames
- Watch mode now works with folders, reacting to source-code changes and adding templates/source files.
- When using watch mode, status info will be displayed in the generated code so that you don't need to look at console at all.
- You can now access types of enum's associated values
- You can now access type's
methods
andinitializers
- You can now access
supertype
of a class - Associated values will now automatically use idx as name if no name is provided
- Fix dealing with multibyte characters
types.implementing
andtypes.based
should include protocols that are based on other protocols
- TDD Development is now easier thanks to Diffable results, no longer we need to scan wall of text on failures, instead we see exactly what's different.
- Added
contains
,hasPrefix
,hasPrefix
filters
- AccessLevel is now stored as string
- Typealiases parsing could cause crash, implemented a workaround for that until we can find a little more reliable solution
- Swift Package Manager support.
- Enum cases also have annotation support
- Improved handling of global and local typealiases.
- Add upperFirst stencil filter
- Fixes a bug with flattening
inherits
,implements
for protocols implementing other protocols - Improve
rawType
logic for Enums
- Annotations can now be declared also with sections e.g.
sourcery:begin: attribute1, attribute2 = 234
- Adds scanning class variables as static
- Refactored models
- Improved performance of annotation scanning
- Implements inherits, implements, based reflection on each Type
- Flattens inheritance, e.g. Foo implements Decodable, then FooSubclass also implements it
- Stop parsing private variables as they wouldn't be accessible to code-generated code
- improve detecting raw type
- add
isGeneric
property
- Enables support for scanning extensions of unknown type, providing partial metadata via types.based or types.all reflection
- Adds real type reflection into Variable, not only it's name
- Resolves known typealiases
- Fixes a bug that caused Sourcery to drop previous type information when encountering generated code, closes #33
- Fixes bug in escaping path
- Fixes missing protocol variant in kind
- added support for type/variable source annotations
- added property kind to Type, it contains info whether this is struct, class or enum entry
- Automatically skips .swift files that were generated with Sourcery
- improved detecting enums with rawType