Skip to content

Commit

Permalink
Ajout d'une erreur pour une association sans rôle sur la classe conte…
Browse files Browse the repository at this point in the history
…nante (fix #302)
  • Loading branch information
JabX committed Sep 20, 2023
1 parent 71a3381 commit ded4c7d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions TopModel.Core/ModelErrorType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ public enum ModelErrorType
/// </summary>
TMD1028,

/// <summary>
/// Cette association sur la classe '{classe}' doit définir un rôle.
/// </summary>
TMD1029,

/// <summary>
/// Le flux de données est introuvable dans le fichier ou l'une de ses références.
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions TopModel.Core/ModelStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,15 @@ IEnumerable<ModelError> ResolveAliases(IEnumerable<AliasProperty> alps)
ModelErrorType = ModelErrorType.TMD0003
};
}

foreach (var property in classe.Properties.OfType<AssociationProperty>().Where(p => p.Association == classe && string.IsNullOrEmpty(p.Role)))
{
yield return new ModelError(modelFile, $"Cette association sur la classe '{classe}' doit définir un rôle.", property.Decorator is not null ? classe.DecoratorReferences.FirstOrDefault(dr => dr.ReferenceName == property.Decorator.Name) : property.GetLocation())
{
IsError = true,
ModelErrorType = ModelErrorType.TMD1029
};
}
}

foreach (var use in modelFile.UselessImports.Where(u => dependencies.Any(d => d.Name == u.ReferenceName)))
Expand Down

0 comments on commit ded4c7d

Please sign in to comment.